2004-08-21 01:25:48 +00:00
/*
Copyright ( C ) 1996 - 1997 Id Software , Inc .
This program is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation ; either version 2
of the License , or ( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
2011-07-01 07:27:38 +00:00
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE .
2004-08-21 01:25:48 +00:00
See the GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*/
// comndef.h -- general definitions
2011-06-29 18:39:11 +00:00
# include <stdio.h>
//make shared
# ifndef QDECL
# ifdef _MSC_VER
# define QDECL _cdecl
# else
# define QDECL
# endif
# endif
2004-08-21 01:25:48 +00:00
typedef unsigned char qbyte ;
// KJB Undefined true and false defined in SciTech's DEBUG.H header
# undef true
# undef false
# ifdef __cplusplus
2005-03-28 00:11:59 +00:00
typedef enum { qfalse , qtrue } qboolean ; //false and true are forcivly defined.
# define true qtrue
# define false qfalse
2004-08-21 01:25:48 +00:00
# else
typedef enum { false , true } qboolean ;
# endif
2011-06-16 02:03:57 +00:00
# define STRINGIFY2(s) #s
# define STRINGIFY(s) STRINGIFY2(s)
2005-03-07 08:58:26 +00:00
# define MAX_INFO_STRING 196 //regular quakeworld. Sickening isn't it.
# define EXTENDED_INFO_STRING 1024
# define MAX_SERVERINFO_STRING 1024 //standard quake has 512 here.
2004-08-21 01:25:48 +00:00
# define MAX_LOCALINFO_STRING 32768
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
struct netprim_s
{
int coordsize ;
int anglesize ;
} ;
2004-08-21 01:25:48 +00:00
//============================================================================
2004-12-24 08:45:56 +00:00
typedef enum {
SZ_BAD ,
SZ_RAWBYTES ,
SZ_RAWBITS ,
SZ_HUFFMAN //q3 style packets are horrible.
} sbpacking_t ;
2004-08-21 01:25:48 +00:00
typedef struct sizebuf_s
{
qboolean allowoverflow ; // if false, do a Sys_Error
qboolean overflowed ; // set to true if the buffer size failed
qbyte * data ;
int maxsize ;
int cursize ;
2004-12-24 08:45:56 +00:00
int packing ;
int currentbit ;
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
struct netprim_s prim ;
2004-08-21 01:25:48 +00:00
} sizebuf_t ;
void SZ_Clear ( sizebuf_t * buf ) ;
void * SZ_GetSpace ( sizebuf_t * buf , int length ) ;
void SZ_Write ( sizebuf_t * buf , const void * data , int length ) ;
void SZ_Print ( sizebuf_t * buf , const char * data ) ; // strcats onto the sizebuf
//============================================================================
typedef struct link_s
{
struct link_s * prev , * next ;
} link_t ;
void ClearLink ( link_t * l ) ;
void RemoveLink ( link_t * l ) ;
void InsertLinkBefore ( link_t * l , link_t * before ) ;
void InsertLinkAfter ( link_t * l , link_t * after ) ;
// (type *)STRUCT_FROM_LINK(link_t *link, type, member)
// ent = STRUCT_FROM_LINK(link,entity_t,order)
// FIXME: remove this mess!
2010-07-11 10:53:13 +00:00
# define STRUCT_FROM_LINK(l,t,m) ((t *)((qbyte *)l - (qbyte*)&(((t *)0)->m)))
2004-08-21 01:25:48 +00:00
//============================================================================
# ifndef NULL
# define NULL ((void *)0)
# endif
# define Q_MAXCHAR ((char)0x7f)
# define Q_MAXSHORT ((short)0x7fff)
# define Q_MAXINT ((int)0x7fffffff)
# define Q_MAXLONG ((int)0x7fffffff)
# define Q_MAXFLOAT ((int)0x7fffffff)
# define Q_MINCHAR ((char)0x80)
# define Q_MINSHORT ((short)0x8000)
# define Q_MININT ((int)0x80000000)
# define Q_MINLONG ((int)0x80000000)
# define Q_MINFLOAT ((int)0x7fffffff)
//============================================================================
2006-07-08 22:35:15 +00:00
extern qboolean bigendian ;
2004-08-21 01:25:48 +00:00
extern short ( * BigShort ) ( short l ) ;
extern short ( * LittleShort ) ( short l ) ;
extern int ( * BigLong ) ( int l ) ;
extern int ( * LittleLong ) ( int l ) ;
extern float ( * BigFloat ) ( float l ) ;
extern float ( * LittleFloat ) ( float l ) ;
2005-07-29 22:26:43 +00:00
short ShortSwap ( short l ) ;
int LongSwap ( int l ) ;
2006-06-04 01:43:52 +00:00
void COM_CharBias ( signed char * c , int size ) ;
void COM_SwapLittleShortBlock ( short * s , int size ) ;
2004-08-21 01:25:48 +00:00
//============================================================================
struct usercmd_s ;
extern struct usercmd_s nullcmd ;
2004-11-17 17:34:14 +00:00
typedef union { //note: reading from packets can be misaligned
char b [ 4 ] ;
short b2 ;
int b4 ;
float f ;
} coorddata ;
float MSG_FromCoord ( coorddata c , int bytes ) ;
coorddata MSG_ToCoord ( float f , int bytes ) ;
2009-11-15 03:20:17 +00:00
coorddata MSG_ToAngle ( float f , int bytes ) ;
2004-11-17 17:34:14 +00:00
2004-08-21 01:25:48 +00:00
void MSG_WriteChar ( sizebuf_t * sb , int c ) ;
void MSG_WriteByte ( sizebuf_t * sb , int c ) ;
void MSG_WriteShort ( sizebuf_t * sb , int c ) ;
void MSG_WriteLong ( sizebuf_t * sb , int c ) ;
void MSG_WriteFloat ( sizebuf_t * sb , float f ) ;
2005-03-28 00:11:59 +00:00
void MSG_WriteString ( sizebuf_t * sb , const char * s ) ;
2004-08-21 01:25:48 +00:00
void MSG_WriteCoord ( sizebuf_t * sb , float f ) ;
void MSG_WriteBigCoord ( sizebuf_t * sb , float f ) ;
void MSG_WriteAngle ( sizebuf_t * sb , float f ) ;
2005-06-14 04:52:10 +00:00
void MSG_WriteAngle8 ( sizebuf_t * sb , float f ) ;
2004-08-21 01:25:48 +00:00
void MSG_WriteAngle16 ( sizebuf_t * sb , float f ) ;
void MSG_WriteDeltaUsercmd ( sizebuf_t * sb , struct usercmd_s * from , struct usercmd_s * cmd ) ;
void MSG_WriteDir ( sizebuf_t * sb , float * dir ) ;
extern int msg_readcount ;
extern qboolean msg_badread ; // set if a read goes beyond end of message
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
struct netprim_s msg_nullnetprim ;
2004-08-21 01:25:48 +00:00
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
void MSG_BeginReading ( struct netprim_s prim ) ;
void MSG_ChangePrimitives ( struct netprim_s prim ) ;
2004-08-21 01:25:48 +00:00
int MSG_GetReadCount ( void ) ;
int MSG_ReadChar ( void ) ;
2005-02-12 18:56:04 +00:00
int MSG_ReadBits ( int bits ) ;
2004-08-21 01:25:48 +00:00
int MSG_ReadByte ( void ) ;
int MSG_ReadShort ( void ) ;
int MSG_ReadLong ( void ) ;
float MSG_ReadFloat ( void ) ;
char * MSG_ReadString ( void ) ;
char * MSG_ReadStringLine ( void ) ;
float MSG_ReadCoord ( void ) ;
void MSG_ReadPos ( float * pos ) ;
float MSG_ReadAngle ( void ) ;
float MSG_ReadAngle16 ( void ) ;
void MSG_ReadDeltaUsercmd ( struct usercmd_s * from , struct usercmd_s * cmd ) ;
void MSGQ2_ReadDeltaUsercmd ( struct usercmd_s * from , struct usercmd_s * move ) ;
void MSG_ReadData ( void * data , int len ) ;
2010-07-18 08:42:59 +00:00
void MSG_ReadSkip ( int len ) ;
2004-08-21 01:25:48 +00:00
//============================================================================
2009-04-01 22:03:56 +00:00
char * Q_strcpyline ( char * out , const char * in , int maxlen ) ; //stops at '\n' (and '\r')
2004-08-21 01:25:48 +00:00
2006-05-19 03:45:44 +00:00
void Q_ftoa ( char * str , float in ) ;
2005-01-24 23:47:32 +00:00
char * Q_strlwr ( char * str ) ;
2009-04-01 22:03:56 +00:00
int wildcmp ( const char * wild , const char * string ) ; //1 if match
2005-01-24 23:47:32 +00:00
2004-08-21 01:25:48 +00:00
# define Q_memset(d, f, c) memset((d), (f), (c))
# define Q_memcpy(d, s, c) memcpy((d), (s), (c))
2010-05-17 02:01:58 +00:00
# define Q_memmove(d, s, c) memmove((d), (s), (c))
2004-08-21 01:25:48 +00:00
# define Q_memcmp(m1, m2, c) memcmp((m1), (m2), (c))
# define Q_strcpy(d, s) strcpy((d), (s))
# define Q_strncpy(d, s, n) strncpy((d), (s), (n))
# define Q_strlen(s) ((int)strlen(s))
# define Q_strrchr(s, c) strrchr((s), (c))
# define Q_strcat(d, s) strcat((d), (s))
# define Q_strcmp(s1, s2) strcmp((s1), (s2))
# define Q_strncmp(s1, s2, n) strncmp((s1), (s2), (n))
2009-11-04 21:16:50 +00:00
void VARGS Q_snprintfz ( char * dest , size_t size , char * fmt , . . . ) LIKEPRINTF ( 3 ) ;
2011-07-01 07:27:38 +00:00
int VARGS Com_sprintf ( char * buffer , int size , const char * format , . . . ) LIKEPRINTF ( 3 ) ;
2005-04-16 16:21:27 +00:00
2004-08-21 01:25:48 +00:00
# define Q_strncpyS(d, s, n) do{const char *____in=(s);char *____out=(d);int ____i; for (____i=0;*(____in); ____i++){if (____i == (n))break;*____out++ = *____in++;}if (____i < (n))*____out='\0';}while(0) //only use this when it should be used. If undiciided, use N
# define Q_strncpyN(d, s, n) do{if (n < 0)Sys_Error("Bad length in strncpyz");Q_strncpyS((d), (s), (n));((char *)(d))[n] = '\0';}while(0) //this'll stop me doing buffer overflows. (guarenteed to overflow if you tried the wrong size.)
2005-04-16 16:21:27 +00:00
//#define Q_strncpyNCHECKSIZE(d, s, n) do{if (n < 1)Sys_Error("Bad length in strncpyz");Q_strncpyS((d), (s), (n));((char *)(d))[n-1] = '\0';((char *)(d))[n] = '255';}while(0) //This forces nothing else to be within the buffer. Should be used for testing and nothing else.
#if 0
2004-08-21 01:25:48 +00:00
# define Q_strncpyz(d, s, n) Q_strncpyN(d, s, (n)-1)
2005-04-16 16:21:27 +00:00
# else
2011-06-29 18:39:11 +00:00
void QDECL Q_strncpyz ( char * d , const char * s , int n ) ;
2005-04-26 16:04:12 +00:00
# define Q_strncatz(dest, src, sizeofdest) \
do { \
strncat ( dest , src , sizeofdest - strlen ( dest ) - 1 ) ; \
dest [ sizeofdest - 1 ] = 0 ; \
} while ( 0 )
# define Q_strncatz2(dest, src) Q_strncatz(dest, src, sizeof(dest))
2005-04-16 16:21:27 +00:00
# endif
2004-08-21 01:25:48 +00:00
//#define Q_strncpy Please remove all strncpys
2011-07-01 07:27:38 +00:00
/*#ifndef strncpy
2004-08-21 01:25:48 +00:00
# define strncpy Q_strncpy
# endif* /
2011-06-29 18:39:11 +00:00
/*replacement functions which do not care for locale in text formatting ('C' locale)*/
int Q_strncasecmp ( const char * s1 , const char * s2 , int n ) ;
int Q_strcasecmp ( const char * s1 , const char * s2 ) ;
2009-04-01 22:03:56 +00:00
int Q_atoi ( const char * str ) ;
float Q_atof ( const char * str ) ;
2011-10-27 16:16:29 +00:00
void deleetstring ( char * result , char * leet ) ;
2004-08-21 01:25:48 +00:00
//============================================================================
extern char com_token [ 1024 ] ;
2008-11-09 22:29:28 +00:00
typedef enum { TTP_UNKNOWN , TTP_STRING , TTP_LINEENDING } com_tokentype_t ;
2004-08-21 01:25:48 +00:00
extern com_tokentype_t com_tokentype ;
extern qboolean com_eof ;
2009-04-01 22:03:56 +00:00
//these cast away the const for the return value.
//char *COM_Parse (const char *data);
# define COM_Parse(d) COM_ParseOut(d,com_token, sizeof(com_token))
char * COM_ParseOut ( const char * data , char * out , int outlen ) ;
char * COM_ParseStringSet ( const char * data ) ;
char * COM_ParseCString ( const char * data ) ;
2011-02-25 04:22:14 +00:00
char * COM_StringParse ( const char * data , char * token , unsigned int tokenlen , qboolean expandmacros , qboolean qctokenize ) ;
2006-09-17 00:59:22 +00:00
char * COM_ParseToken ( const char * data , const char * punctuation ) ;
2004-08-21 01:25:48 +00:00
char * COM_TrimString ( char * str ) ;
extern int com_argc ;
2009-04-01 22:03:56 +00:00
extern const char * * com_argv ;
2004-08-21 01:25:48 +00:00
2009-04-01 22:03:56 +00:00
int COM_CheckParm ( const char * parm ) ;
int COM_CheckNextParm ( const char * parm , int last ) ;
void COM_AddParm ( const char * parm ) ;
2004-08-21 01:25:48 +00:00
void COM_Init ( void ) ;
2009-04-01 22:03:56 +00:00
void COM_InitArgv ( int argc , const char * * argv ) ;
2005-01-16 02:26:29 +00:00
void COM_ParsePlusSets ( void ) ;
2004-08-21 01:25:48 +00:00
2009-05-24 10:11:17 +00:00
typedef unsigned int conchar_t ;
void COM_DeFunString ( conchar_t * str , char * out , int outsize , qboolean ignoreflags ) ;
2009-11-04 21:16:50 +00:00
conchar_t * COM_ParseFunString ( conchar_t defaultflags , const char * str , conchar_t * out , int outsize , qboolean keepmarkup ) ; //ext is usually CON_WHITEMASK, returns its null terminator
2009-05-24 10:11:17 +00:00
int COM_FunStringLength ( unsigned char * str ) ;
2009-04-01 22:03:56 +00:00
char * COM_SkipPath ( const char * pathname ) ;
void COM_StripExtension ( const char * in , char * out , int outlen ) ;
2009-11-04 21:16:50 +00:00
void COM_StripAllExtensions ( char * in , char * out , int outlen ) ;
2009-04-01 22:03:56 +00:00
void COM_FileBase ( const char * in , char * out , int outlen ) ;
int COM_FileSize ( const char * path ) ;
2006-03-11 03:12:10 +00:00
void COM_DefaultExtension ( char * path , char * extension , int maxlen ) ;
2009-04-01 22:03:56 +00:00
char * COM_FileExtension ( const char * in ) ;
2005-03-18 06:13:36 +00:00
void COM_CleanUpPath ( char * str ) ;
2004-08-21 01:25:48 +00:00
2009-11-04 21:16:50 +00:00
char * VARGS va ( char * format , . . . ) LIKEPRINTF ( 1 ) ;
2004-08-21 01:25:48 +00:00
// does a varargs printf into a temp buffer
//============================================================================
2005-09-09 23:40:55 +00:00
extern qboolean com_file_copyprotected ;
2004-08-21 01:25:48 +00:00
extern int com_filesize ;
struct cache_user_s ;
2005-12-21 03:07:33 +00:00
extern char com_quakedir [ MAX_OSPATH ] ;
extern char com_homedir [ MAX_OSPATH ] ;
extern char com_configdir [ MAX_OSPATH ] ; //dir to put cfg_save configs in
//extern char *com_basedir;
2004-08-21 01:25:48 +00:00
2009-04-02 22:25:54 +00:00
void COM_WriteFile ( const char * filename , const void * data , int len ) ;
2012-04-24 07:59:11 +00:00
FTE_DEPRECATED FILE * COM_WriteFileOpen ( char * filename ) ;
2004-08-21 01:25:48 +00:00
typedef struct {
struct searchpath_s * search ;
int index ;
char rawname [ MAX_OSPATH ] ;
int offset ;
int len ;
} flocation_t ;
2008-11-09 22:29:28 +00:00
struct vfsfile_s ;
2004-08-21 01:25:48 +00:00
2005-12-21 03:07:33 +00:00
typedef enum { FSLFRT_IFFOUND , FSLFRT_LENGTH , FSLFRT_DEPTH_OSONLY , FSLFRT_DEPTH_ANYPATH } FSLF_ReturnType_e ;
2004-08-21 01:25:48 +00:00
//if loc is valid, loc->search is always filled in, the others are filled on success.
//returns -1 if couldn't find.
2009-04-01 22:03:56 +00:00
int FS_FLocateFile ( const char * filename , FSLF_ReturnType_e returntype , flocation_t * loc ) ;
2008-11-09 22:29:28 +00:00
struct vfsfile_s * FS_OpenReadLocation ( flocation_t * location ) ;
char * FS_WhichPackForLocation ( flocation_t * loc ) ;
2012-01-24 04:24:14 +00:00
qboolean FS_GetPackageDownloadable ( const char * package ) ;
2006-01-28 02:35:40 +00:00
char * FS_GetPackHashes ( char * buffer , int buffersize , qboolean referencedonly ) ;
2011-12-05 15:23:40 +00:00
char * FS_GetPackNames ( char * buffer , int buffersize , int referencedonly , qboolean ext ) ;
void FS_ReferenceControl ( unsigned int refflag , unsigned int resetflags ) ;
2004-08-21 01:25:48 +00:00
2012-04-24 07:59:11 +00:00
FTE_DEPRECATED int COM_FOpenFile ( const char * filename , FILE * * file ) ;
FTE_DEPRECATED int COM_FOpenWriteFile ( const char * filename , FILE * * file ) ;
2005-08-07 18:08:13 +00:00
//#ifdef _MSC_VER //this is enough to annoy me, without conflicting with other (more bizzare) platforms.
//#define fopen dont_use_fopen
//#endif
2004-08-21 01:25:48 +00:00
2012-04-24 07:59:11 +00:00
FTE_DEPRECATED void COM_CloseFile ( FILE * h ) ;
2004-08-21 01:25:48 +00:00
# define COM_FDepthFile(filename,ignorepacks) FS_FLocateFile(filename,ignorepacks?FSLFRT_DEPTH_OSONLY:FSLFRT_DEPTH_ANYPATH, NULL)
2006-01-28 19:34:21 +00:00
# define COM_FCheckExists(filename) FS_FLocateFile(filename,FSLFRT_IFFOUND, NULL)
2004-08-21 01:25:48 +00:00
2005-12-21 03:07:33 +00:00
typedef struct vfsfile_s {
int ( * ReadBytes ) ( struct vfsfile_s * file , void * buffer , int bytestoread ) ;
2009-04-01 22:03:56 +00:00
int ( * WriteBytes ) ( struct vfsfile_s * file , const void * buffer , int bytestoread ) ;
2005-12-21 03:07:33 +00:00
qboolean ( * Seek ) ( struct vfsfile_s * file , unsigned long pos ) ; //returns false for error
unsigned long ( * Tell ) ( struct vfsfile_s * file ) ;
unsigned long ( * GetLen ) ( struct vfsfile_s * file ) ; //could give some lag
void ( * Close ) ( struct vfsfile_s * file ) ;
2005-12-22 02:29:11 +00:00
void ( * Flush ) ( struct vfsfile_s * file ) ;
2006-02-11 02:09:43 +00:00
qboolean seekingisabadplan ;
2005-12-21 03:07:33 +00:00
} vfsfile_t ;
# define VFS_CLOSE(vf) (vf->Close(vf))
# define VFS_TELL(vf) (vf->Tell(vf))
# define VFS_GETLEN(vf) (vf->GetLen(vf))
# define VFS_SEEK(vf,pos) (vf->Seek(vf,pos))
# define VFS_READ(vf,buffer,buflen) (vf->ReadBytes(vf,buffer,buflen))
# define VFS_WRITE(vf,buffer,buflen) (vf->WriteBytes(vf,buffer,buflen))
2005-12-22 02:29:11 +00:00
# define VFS_FLUSH(vf) do{if(vf->Flush)vf->Flush(vf);}while(0)
2009-04-01 22:03:56 +00:00
# define VFS_PUTS(vf,s) do{const char *t=s;vf->WriteBytes(vf,t,strlen(t));}while(0)
2006-01-12 22:21:32 +00:00
char * VFS_GETS ( vfsfile_t * vf , char * buffer , int buflen ) ;
2009-11-04 21:16:50 +00:00
void VARGS VFS_PRINTF ( vfsfile_t * vf , char * fmt , . . . ) LIKEPRINTF ( 2 ) ;
2009-04-01 22:03:56 +00:00
enum fs_relative {
FS_GAME , //standard search (not generally valid for save/rename/delete/etc)
FS_ROOT , //./
FS_GAMEONLY , //$gamedir/
2012-04-09 19:12:12 +00:00
FS_GAMEDOWNLOADCACHE , //typically the same as FS_GAMEONLY
2009-04-01 22:03:56 +00:00
FS_CONFIGONLY , //fte/ (should still be part of the game path)
FS_SKINS //qw/skins/
} ;
2005-12-21 03:07:33 +00:00
2006-01-28 02:35:40 +00:00
void FS_FlushFSHash ( void ) ;
2009-04-01 22:03:56 +00:00
void FS_CreatePath ( const char * pname , enum fs_relative relativeto ) ;
2012-04-24 07:59:11 +00:00
qboolean FS_Rename ( const char * oldf , const char * newf , enum fs_relative relativeto ) ; //0 on success, non-0 on error
qboolean FS_Rename2 ( const char * oldf , const char * newf , enum fs_relative oldrelativeto , enum fs_relative newrelativeto ) ;
qboolean FS_Remove ( const char * fname , enum fs_relative relativeto ) ; //0 on success, non-0 on error
2009-04-06 00:34:32 +00:00
qboolean FS_Copy ( const char * source , const char * dest , enum fs_relative relativesource , enum fs_relative relativedest ) ;
2009-04-01 22:03:56 +00:00
qboolean FS_NativePath ( const char * fname , enum fs_relative relativeto , char * out , int outlen ) ; //if you really need to fopen yourself
qboolean FS_WriteFile ( const char * filename , const void * data , int len , enum fs_relative relativeto ) ;
vfsfile_t * FS_OpenVFS ( const char * filename , const char * mode , enum fs_relative relativeto ) ;
2006-02-11 02:09:43 +00:00
vfsfile_t * FS_OpenTemp ( void ) ;
2009-04-01 22:03:56 +00:00
vfsfile_t * FS_OpenTCP ( const char * name ) ;
2006-02-11 14:51:36 +00:00
void FS_UnloadPackFiles ( void ) ;
void FS_ReloadPackFiles ( void ) ;
2009-04-01 22:03:56 +00:00
char * FSQ3_GenerateClientPacksList ( char * buffer , int maxlen , int basechecksum ) ;
2005-12-21 03:07:33 +00:00
2012-04-24 07:59:11 +00:00
FTE_DEPRECATED int COM_filelength ( FILE * f ) ;
2009-04-01 22:03:56 +00:00
qbyte * COM_LoadStackFile ( const char * path , void * buffer , int bufsize ) ;
qbyte * COM_LoadTempFile ( const char * path ) ;
2012-02-27 12:23:15 +00:00
qbyte * COM_LoadTempMoreFile ( const char * path ) ; //allocates a little bit more without freeing old temp
2009-04-01 22:03:56 +00:00
qbyte * COM_LoadHunkFile ( const char * path ) ;
2010-05-17 01:47:51 +00:00
qbyte * COM_LoadMallocFile ( const char * path ) ;
2009-04-01 22:03:56 +00:00
void COM_LoadCacheFile ( const char * path , struct cache_user_s * cu ) ;
void FS_ForceToPure ( const char * str , const char * crcs , int seed ) ;
2011-10-27 16:16:29 +00:00
void FS_ImpurePacks ( const char * names , const char * crcs ) ;
2004-11-23 01:14:00 +00:00
char * COM_GetPathInfo ( int i , int * crc ) ;
2004-08-21 01:25:48 +00:00
char * COM_NextPath ( char * prevpath ) ;
void COM_FlushFSCache ( void ) ; //a file was written using fopen
void COM_RefreshFSCache_f ( void ) ;
2010-07-11 02:22:39 +00:00
qboolean FS_Restarted ( unsigned int * since ) ;
2004-08-21 01:25:48 +00:00
2009-11-04 21:16:50 +00:00
void COM_InitFilesystem ( void ) ;
void FS_Shutdown ( void ) ;
void COM_Gamedir ( const char * dir ) ;
char * FS_GetGamedir ( void ) ;
2012-02-12 05:51:51 +00:00
char * FS_GetBasedir ( void ) ;
2009-11-04 21:16:50 +00:00
qbyte * FS_LoadMallocFile ( const char * path ) ;
2009-05-24 10:11:17 +00:00
int FS_LoadFile ( char * name , void * * file ) ;
void FS_FreeFile ( void * file ) ;
2011-03-12 13:51:40 +00:00
qbyte * COM_LoadFile ( const char * path , int usehunk ) ;
2009-04-01 22:03:56 +00:00
qboolean COM_LoadMapPackFile ( const char * name , int offset ) ;
2004-08-21 01:25:48 +00:00
void COM_FlushTempoaryPacks ( void ) ;
2009-04-01 22:03:56 +00:00
void COM_EnumerateFiles ( const char * match , int ( * func ) ( const char * , int , void * ) , void * parm ) ;
2004-08-21 01:25:48 +00:00
extern struct cvar_s registered ;
2005-08-26 22:56:51 +00:00
extern qboolean standard_quake ; //fixme: remove
2004-08-21 01:25:48 +00:00
2008-11-28 20:34:51 +00:00
void COM_Effectinfo_Clear ( void ) ;
2009-04-01 22:03:56 +00:00
unsigned int COM_Effectinfo_ForName ( const char * efname ) ;
2008-11-09 22:29:28 +00:00
char * COM_Effectinfo_ForNumber ( unsigned int efnum ) ;
2009-11-04 21:16:50 +00:00
unsigned int COM_RemapMapChecksum ( unsigned int checksum ) ;
2010-07-11 02:22:39 +00:00
# define MAX_INFO_KEY 256
2005-03-28 00:11:59 +00:00
char * Info_ValueForKey ( char * s , const char * key ) ;
void Info_RemoveKey ( char * s , const char * key ) ;
2005-11-30 01:20:53 +00:00
char * Info_KeyForNumber ( char * s , int num ) ;
2004-08-21 01:25:48 +00:00
void Info_RemovePrefixedKeys ( char * start , char prefix ) ;
void Info_RemoveNonStarKeys ( char * start ) ;
2005-03-28 00:11:59 +00:00
void Info_SetValueForKey ( char * s , const char * key , const char * value , int maxsize ) ;
void Info_SetValueForStarKey ( char * s , const char * key , const char * value , int maxsize ) ;
2004-08-21 01:25:48 +00:00
void Info_Print ( char * s ) ;
2005-12-21 03:07:33 +00:00
void Info_WriteToFile ( vfsfile_t * f , char * info , char * commandname , int cvarflags ) ;
2004-08-21 01:25:48 +00:00
2011-07-30 14:14:56 +00:00
void Com_BlocksChecksum ( int blocks , void * * buffer , int * len , unsigned char * outbuf ) ;
2005-11-03 23:46:31 +00:00
unsigned int Com_BlockChecksum ( void * buffer , int length ) ;
2004-08-21 01:25:48 +00:00
void Com_BlockFullChecksum ( void * buffer , int len , unsigned char * outbuf ) ;
qbyte COM_BlockSequenceCheckByte ( qbyte * base , int length , int sequence , unsigned mapchecksum ) ;
qbyte COM_BlockSequenceCRCByte ( qbyte * base , int length , int sequence ) ;
qbyte Q2COM_BlockSequenceCRCByte ( qbyte * base , int length , int sequence ) ;
2011-03-30 15:17:55 +00:00
int version_number ( void ) ;
char * version_string ( void ) ;
2004-08-21 01:25:48 +00:00
void TL_InitLanguages ( void ) ;
void T_FreeStrings ( void ) ;
char * T_GetString ( int num ) ;
2010-08-16 02:03:02 +00:00
void T_FreeInfoStrings ( void ) ;
char * T_GetInfoString ( int num ) ;
2004-08-21 01:25:48 +00:00
2007-08-07 14:41:23 +00:00
//
// log.c
//
typedef enum {
LOG_CONSOLE ,
LOG_PLAYER ,
LOG_TYPES
} logtype_t ;
void Log_Dir_Callback ( struct cvar_s * var , char * oldvalue ) ;
void Log_Name_Callback ( struct cvar_s * var , char * oldvalue ) ;
void Log_String ( logtype_t lognum , char * s ) ;
void Con_Log ( char * s ) ;
void Log_Logfile_f ( void ) ;
void Log_Init ( void ) ;
2011-06-29 18:39:11 +00:00
/*used by and for botlib and q3 gamecode*/
# define MAX_TOKENLENGTH 1024
typedef struct pc_token_s
{
int type ;
int subtype ;
int intvalue ;
float floatvalue ;
char string [ MAX_TOKENLENGTH ] ;
} pc_token_t ;
# define fileHandle_t int
# define fsMode_t int
2011-12-24 04:05:28 +00:00
typedef struct
{
int sec ;
int min ;
int hour ;
int day ;
int mon ;
int year ;
char str [ 128 ] ;
} date_t ;
void COM_TimeOfDay ( date_t * date ) ;