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
2006-01-27 02:45:16 +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 .
*/
// common.c -- misc functions used in client and server
# include "quakedef.h"
2013-05-11 05:03:07 +00:00
# include <wctype.h>
2005-02-28 07:16:19 +00:00
# include <ctype.h>
2011-05-30 04:32:04 +00:00
# include <errno.h>
2004-08-21 01:25:48 +00:00
2010-11-11 09:06:36 +00:00
// These 4 libraries required for the version command
2004-08-21 01:25:48 +00:00
2010-11-11 09:06:36 +00:00
# if defined(MINGW)
# if defined(AVAIL_PNGLIB) && !defined(SERVERONLY)
# include "./mingw-libs/png.h"
# endif
# ifdef AVAIL_ZLIB
# include "./mingw-libs/zlib.h"
# endif
# if defined(AVAIL_JPEGLIB) && !defined(SERVERONLY)
# define JPEG_API VARGS
2010-11-11 09:14:30 +00:00
//#include "./mingw-libs/jversion.h"
2010-11-11 09:06:36 +00:00
# include "./mingw-libs/jpeglib.h"
# endif
2014-02-09 09:25:28 +00:00
# ifdef FTE_SDL
2014-02-07 08:38:40 +00:00
# include <SDL.h>
2010-11-14 10:16:40 +00:00
# endif
2010-11-11 09:06:36 +00:00
# elif defined(_WIN32)
# if defined(AVAIL_PNGLIB) && !defined(SERVERONLY)
# include "png.h"
# endif
# ifdef AVAIL_ZLIB
# include "zlib.h"
# endif
# if defined(AVAIL_JPEGLIB) && !defined(SERVERONLY)
# define JPEG_API VARGS
2010-11-11 09:14:30 +00:00
//#include "jversion.h"
2010-11-11 09:06:36 +00:00
# include "jpeglib.h"
# endif
2014-02-09 09:25:28 +00:00
# ifdef FTE_SDL
2014-02-07 08:38:40 +00:00
# include <SDL.h>
2010-11-14 10:16:40 +00:00
# endif
2010-11-11 09:06:36 +00:00
# else
# if defined(AVAIL_PNGLIB) && !defined(SERVERONLY)
# include <png.h>
# endif
# ifdef AVAIL_ZLIB
# include <zlib.h>
# endif
# if defined(AVAIL_JPEGLIB) && !defined(SERVERONLY)
2010-11-11 09:14:30 +00:00
//#include <jversion.h>
2010-11-11 09:06:36 +00:00
# include <jpeglib.h>
# endif
2014-02-09 09:25:28 +00:00
# ifdef FTE_SDL
2014-02-07 08:38:40 +00:00
# include <SDL.h>
2010-11-14 10:16:40 +00:00
# endif
2010-11-11 09:06:36 +00:00
# endif
2004-08-21 01:25:48 +00:00
# define NUM_SAFE_ARGVS 6
usercmd_t nullcmd ; // guarenteed to be zero
2006-02-27 00:42:25 +00:00
entity_state_t nullentitystate ; //this is the default state
2009-04-01 22:03:56 +00:00
static const char * largv [ MAX_NUM_ARGVS + NUM_SAFE_ARGVS + 1 ] ;
2004-08-21 01:25:48 +00:00
static char * argvdummy = " " ;
static char * safeargvs [ NUM_SAFE_ARGVS ] =
{ " -stdvid " , " -nolan " , " -nosound " , " -nocdaudio " , " -nojoy " , " -nomouse " } ;
2010-07-11 02:22:39 +00:00
cvar_t registered = CVARD ( " registered " , " 0 " , " Set if quake's pak1.pak is available " ) ;
cvar_t gameversion = CVARFD ( " gameversion " , " " , CVAR_SERVERINFO , " gamecode version for server browsers " ) ;
2011-05-20 04:10:46 +00:00
cvar_t gameversion_min = CVARD ( " gameversion_min " , " " , " gamecode version for server browsers " ) ;
cvar_t gameversion_max = CVARD ( " gameversion_max " , " " , " gamecode version for server browsers " ) ;
2011-07-30 14:14:56 +00:00
cvar_t fs_gamename = CVARFD ( " fs_gamename " , " " , CVAR_NOSET , " The filesystem is trying to run this game " ) ;
2013-06-23 02:17:02 +00:00
cvar_t fs_gamemanifest = CVARFD ( " fs_gamemanifest " , " " , CVAR_NOSET , " A small updatable file containing a description of the game, including download mirrors. " ) ;
2011-07-30 14:14:56 +00:00
cvar_t com_protocolname = CVARD ( " com_gamename " , " " , " The game name used for dpmaster queries " ) ;
2010-07-11 02:22:39 +00:00
cvar_t com_modname = CVARD ( " com_modname " , " " , " dpmaster information " ) ;
2012-02-14 15:50:34 +00:00
cvar_t com_parseutf8 = CVARD ( " com_parseutf8 " , " 0 " , " Interpret console messages/playernames/etc as UTF-8. Requires special fonts. -1=iso 8859-1. 0=quakeascii(chat uses high chars). 1=utf8, revert to ascii on decode errors. 2=utf8 ignoring errors " ) ; //1 parse. 2 parse, but stop parsing that string if a char was malformed.
2014-10-05 20:04:11 +00:00
cvar_t com_parseezquake = CVARD ( " com_parseezquake " , " 0 " , " Treat chevron chars from configs as a per-character flag. You should use this only for compat with nquake's configs. " ) ;
2012-02-14 15:50:34 +00:00
cvar_t com_highlightcolor = CVARD ( " com_highlightcolor " , STRINGIFY ( COLOR_RED ) , " ANSI colour to be used for highlighted text, used when com_parseutf8 is active. " ) ;
2014-10-05 20:04:11 +00:00
cvar_t com_nogamedirnativecode = CVARFD ( " com_nogamedirnativecode " , " 1 " , CVAR_NOTFROMSERVER , FULLENGINENAME " blocks all downloads of files with a .dll or .so extension, however other engines (eg: ezquake and fodquake) do not - this omission can be used to trigger remote exploits in any engine (including " DISTRIBUTION " ) which is later run from the same gamedir. \n Quake2, Quake3(when debugging), and KTX typically run native gamecode from within gamedirs, so if you wish to run any of these games you will need to ensure this cvar is changed to 0, as well as ensure that you don't run unsafe clients. \n " ) ;
2014-09-17 03:04:08 +00:00
cvar_t sys_platform = CVAR ( " sys_platform " , PLATFORM ) ;
2004-08-21 01:25:48 +00:00
qboolean com_modified ; // set true if using non-id files
2005-03-28 00:11:59 +00:00
qboolean static_registered = true ; // only for startup check, then set
2004-08-21 01:25:48 +00:00
2005-03-28 00:11:59 +00:00
qboolean msg_suppress_1 = false ;
2014-05-30 03:57:30 +00:00
int isPlugin ; //if 2, we qcdebug to external program
2004-08-21 01:25:48 +00:00
void COM_Path_f ( void ) ;
2005-01-04 07:49:23 +00:00
void COM_Dir_f ( void ) ;
void COM_Locate_f ( void ) ;
2004-08-21 01:25:48 +00:00
// if a packfile directory differs from this, it is assumed to be hacked
# define PAK0_COUNT 339
# define PAK0_CRC 52883
qboolean standard_quake = true , rogue , hipnotic ;
/*
All of Quake ' s data access is through a hierchal file system , but the contents of the file system can be transparently merged from several sources .
The " base directory " is the path to the directory holding the quake . exe and all game directories . The sys_ * files pass this to host_init in quakeparms_t - > basedir . This can be overridden with the " -basedir " command line parm to allow code debugging in a different directory . The base directory is
only used during filesystem initialization .
The " game directory " is the first tree on the search path and directory that all generated files ( savegames , screenshots , demos , config files ) will be saved to . This can be overridden with the " -game " command line parameter . The game directory can never be changed while quake is executing . This is a precacution against having a malicious server instruct clients to write files over areas they shouldn ' t .
The " cache directory " is only used during development to save network bandwidth , especially over ISDN / T1 lines . If there is a cache directory
specified , when a file is found by the normal search path , it will be mirrored
into the cache directory , then opened there .
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
*/
//============================================================================
// ClearLink is used for new headnodes
void ClearLink ( link_t * l )
{
l - > prev = l - > next = l ;
}
void RemoveLink ( link_t * l )
{
l - > next - > prev = l - > prev ;
l - > prev - > next = l - > next ;
}
void InsertLinkBefore ( link_t * l , link_t * before )
{
l - > next = before ;
l - > prev = before - > prev ;
l - > prev - > next = l ;
l - > next - > prev = l ;
}
void InsertLinkAfter ( link_t * l , link_t * after )
{
l - > next = after - > next ;
l - > prev = after ;
l - > prev - > next = l ;
l - > next - > prev = l ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
LIBRARY REPLACEMENT FUNCTIONS
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
2011-06-29 18:39:11 +00:00
void QDECL Q_strncpyz ( char * d , const char * s , int n )
2005-04-16 16:21:27 +00:00
{
int i ;
n - - ;
if ( n < 0 )
return ; //this could be an error
for ( i = 0 ; * s ; i + + )
{
if ( i = = n )
break ;
* d + + = * s + + ;
}
* d = ' \0 ' ;
}
2012-07-05 19:42:36 +00:00
//windows/linux have inconsistant snprintf
//this is an attempt to get them consistant and safe
//size is the total size of the buffer
2012-11-27 03:23:19 +00:00
void VARGS Q_vsnprintfz ( char * dest , size_t size , const char * fmt , va_list argptr )
2012-07-05 19:42:36 +00:00
{
vsnprintf ( dest , size , fmt , argptr ) ;
dest [ size - 1 ] = 0 ;
}
2005-11-30 01:20:53 +00:00
//windows/linux have inconsistant snprintf
//this is an attempt to get them consistant and safe
//size is the total size of the buffer
2012-11-27 03:23:19 +00:00
void VARGS Q_snprintfz ( char * dest , size_t size , const char * fmt , . . . )
2005-11-30 01:20:53 +00:00
{
va_list argptr ;
va_start ( argptr , fmt ) ;
2012-07-05 19:42:36 +00:00
Q_vsnprintfz ( dest , size , fmt , argptr ) ;
2005-11-30 01:20:53 +00:00
va_end ( argptr ) ;
}
2005-04-16 16:21:27 +00:00
2004-08-21 01:25:48 +00:00
#if 0
void Q_memset ( void * dest , int fill , int count )
{
int i ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
if ( ( ( ( long ) dest | count ) & 3 ) = = 0 )
{
count > > = 2 ;
fill = fill | ( fill < < 8 ) | ( fill < < 16 ) | ( fill < < 24 ) ;
for ( i = 0 ; i < count ; i + + )
( ( int * ) dest ) [ i ] = fill ;
}
else
for ( i = 0 ; i < count ; i + + )
( ( qbyte * ) dest ) [ i ] = fill ;
}
void Q_memcpy ( void * dest , void * src , int count )
{
int i ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
if ( ( ( ( long ) dest | ( long ) src | count ) & 3 ) = = 0 )
{
count > > = 2 ;
for ( i = 0 ; i < count ; i + + )
( ( int * ) dest ) [ i ] = ( ( int * ) src ) [ i ] ;
}
else
for ( i = 0 ; i < count ; i + + )
( ( qbyte * ) dest ) [ i ] = ( ( qbyte * ) src ) [ i ] ;
}
int Q_memcmp ( void * m1 , void * m2 , int count )
{
while ( count )
{
count - - ;
if ( ( ( qbyte * ) m1 ) [ count ] ! = ( ( qbyte * ) m2 ) [ count ] )
return - 1 ;
}
return 0 ;
}
void Q_strcpy ( char * dest , char * src )
{
while ( * src )
{
* dest + + = * src + + ;
}
* dest + + = 0 ;
}
void Q_strncpy ( char * dest , char * src , int count )
{
while ( * src & & count - - )
{
* dest + + = * src + + ;
}
if ( count )
* dest + + = 0 ;
}
int Q_strlen ( char * str )
{
int count ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
count = 0 ;
while ( str [ count ] )
count + + ;
return count ;
}
char * Q_strrchr ( char * s , char c )
{
int len = Q_strlen ( s ) ;
s + = len ;
while ( len - - )
if ( * - - s = = c ) return s ;
return 0 ;
}
void Q_strcat ( char * dest , char * src )
{
dest + = Q_strlen ( dest ) ;
Q_strcpy ( dest , src ) ;
}
int Q_strcmp ( char * s1 , char * s2 )
{
while ( 1 )
{
if ( * s1 ! = * s2 )
2006-01-27 02:45:16 +00:00
return - 1 ; // strings not equal
2004-08-21 01:25:48 +00:00
if ( ! * s1 )
return 0 ; // strings are equal
s1 + + ;
s2 + + ;
}
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
return - 1 ;
}
int Q_strncmp ( char * s1 , char * s2 , int count )
{
while ( 1 )
{
if ( ! count - - )
return 0 ;
if ( * s1 ! = * s2 )
2006-01-27 02:45:16 +00:00
return - 1 ; // strings not equal
2004-08-21 01:25:48 +00:00
if ( ! * s1 )
return 0 ; // strings are equal
s1 + + ;
s2 + + ;
}
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
return - 1 ;
}
2011-06-29 18:39:11 +00:00
# endif
int Q_strncasecmp ( const char * s1 , const char * s2 , int n )
2004-08-21 01:25:48 +00:00
{
int c1 , c2 ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
while ( 1 )
{
c1 = * s1 + + ;
c2 = * s2 + + ;
if ( ! n - - )
return 0 ; // strings are equal until end point
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
if ( c1 ! = c2 )
{
if ( c1 > = ' a ' & & c1 < = ' z ' )
c1 - = ( ' a ' - ' A ' ) ;
if ( c2 > = ' a ' & & c2 < = ' z ' )
c2 - = ( ' a ' - ' A ' ) ;
if ( c1 ! = c2 )
return - 1 ; // strings not equal
}
if ( ! c1 )
return 0 ; // strings are equal
// s1++;
// s2++;
}
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
return - 1 ;
}
2011-06-29 18:39:11 +00:00
int Q_strcasecmp ( const char * s1 , const char * s2 )
{
return Q_strncasecmp ( s1 , s2 , 99999 ) ;
}
int QDECL Q_stricmp ( const char * s1 , const char * s2 )
2004-08-21 01:25:48 +00:00
{
return Q_strncasecmp ( s1 , s2 , 99999 ) ;
}
2014-10-05 20:04:11 +00:00
char * Q_strcasestr ( const char * haystack , const char * needle )
{
int c1 , c2 , c2f ;
int i ;
c2f = * needle ;
if ( c2f > = ' a ' & & c2f < = ' z ' )
c2f - = ( ' a ' - ' A ' ) ;
if ( ! c2f )
return ( char * ) haystack ;
while ( 1 )
{
c1 = * haystack ;
if ( ! c1 )
return NULL ;
if ( c1 > = ' a ' & & c1 < = ' z ' )
c1 - = ( ' a ' - ' A ' ) ;
if ( c1 = = c2f )
{
for ( i = 1 ; ; i + + )
{
c1 = haystack [ i ] ;
c2 = needle [ i ] ;
if ( c1 > = ' a ' & & c1 < = ' z ' )
c1 - = ( ' a ' - ' A ' ) ;
if ( c2 > = ' a ' & & c2 < = ' z ' )
c2 - = ( ' a ' - ' A ' ) ;
if ( ! c2 )
return ( char * ) haystack ; //end of needle means we found a complete match
if ( ! c1 ) //end of haystack means we can't possibly find needle in it any more
return NULL ;
if ( c1 ! = c2 ) //mismatch means no match starting at haystack[0]
break ;
}
}
haystack + + ;
}
return NULL ; //didn't find it
}
2011-06-29 18:39:11 +00:00
int QDECL Q_vsnprintf ( char * buffer , int size , const char * format , va_list argptr )
{
return vsnprintf ( buffer , size , format , argptr ) ;
}
2011-07-01 07:27:38 +00:00
int VARGS Com_sprintf ( char * buffer , int size , const char * format , . . . )
2011-06-29 18:39:11 +00:00
{
int ret ;
va_list argptr ;
va_start ( argptr , format ) ;
ret = vsnprintf ( buffer , size , format , argptr ) ;
va_end ( argptr ) ;
return ret ;
}
void QDECL Com_Error ( int level , const char * error , . . . )
{
Sys_Error ( " %s " , error ) ;
}
2004-08-21 01:25:48 +00:00
char * Q_strlwr ( char * s )
{
char * ret = s ;
while ( * s )
{
if ( * s > = ' A ' & & * s < = ' Z ' )
* s = * s - ' A ' + ' a ' ;
s + + ;
}
return ret ;
}
2009-04-01 22:03:56 +00:00
int wildcmp ( const char * wild , const char * string )
2004-08-21 01:25:48 +00:00
{
2012-11-27 03:23:19 +00:00
/*
2005-03-20 02:57:11 +00:00
while ( ( * string ) & & ( * wild ! = ' * ' ) )
2004-08-21 01:25:48 +00:00
{
2005-03-20 02:57:11 +00:00
if ( ( * wild ! = * string ) & & ( * wild ! = ' ? ' ) )
{
return 0 ;
}
wild + + ;
string + + ;
}
2012-11-27 03:23:19 +00:00
*/
2005-03-20 02:57:11 +00:00
while ( * string )
{
if ( * wild = = ' * ' )
2004-08-21 01:25:48 +00:00
{
2013-11-21 23:02:28 +00:00
if ( * string = = ' / ' | | * string = = ' \\ ' )
2004-08-21 01:25:48 +00:00
{
2012-11-27 03:23:19 +00:00
//* terminates if we get a match on the char following it, or if its a \ or / char
wild + + ;
continue ;
2005-03-20 02:57:11 +00:00
}
2013-11-21 23:02:28 +00:00
if ( wildcmp ( wild + 1 , string ) )
return true ;
2012-11-27 03:23:19 +00:00
string + + ;
2005-03-20 02:57:11 +00:00
}
else if ( ( * wild = = * string ) | | ( * wild = = ' ? ' ) )
{
2012-11-27 03:23:19 +00:00
//this char matches
2005-03-20 02:57:11 +00:00
wild + + ;
string + + ;
2004-08-21 01:25:48 +00:00
}
else
{
2012-11-27 03:23:19 +00:00
//failure
return false ;
2004-08-21 01:25:48 +00:00
}
}
2006-01-27 02:45:16 +00:00
2005-03-20 02:57:11 +00:00
while ( * wild = = ' * ' )
{
wild + + ;
}
return ! * wild ;
2004-08-21 01:25:48 +00:00
}
2006-05-19 19:15:52 +00:00
// Q_ftoa: convert IEEE 754 float to a base-10 string with "infinite" decimal places
void Q_ftoa ( char * str , float in )
{
unsigned int i = * ( ( int * ) & in ) ;
int signbit = ( i & 0x80000000 ) > > 31 ;
int exp = ( signed int ) ( ( i & 0x7F800000 ) > > 23 ) - 127 ;
int mantissa = ( i & 0x007FFFFF ) ;
if ( exp = = 128 ) // 255(NaN/Infinity bits) - 127(bias)
{
if ( signbit )
{
* str = ' - ' ;
str + + ;
}
if ( mantissa = = 0 ) // infinity
strcpy ( str , " 1.#INF " ) ;
else // NaN or indeterminate
strcpy ( str , " 1.#NAN " ) ;
return ;
}
exp = - exp ;
exp = ( int ) ( exp * 0.30102999957f ) ; // convert base 2 to base 10
exp + = 8 ;
if ( exp < = 0 )
sprintf ( str , " %.0f " , in ) ;
else
{
char tstr [ 8 ] ;
char * lsig = str - 1 ;
sprintf ( tstr , " %%.%if " , exp ) ;
sprintf ( str , tstr , in ) ;
// find last significant digit and trim
while ( * str )
{
if ( * str > = ' 1 ' & & * str < = ' 9 ' )
lsig = str ;
else if ( * str = = ' . ' )
lsig = str - 1 ;
str + + ;
}
lsig [ 1 ] = ' \0 ' ;
}
}
2013-05-03 04:28:08 +00:00
static int dehex ( int i )
{
if ( i > = ' 0 ' & & i < = ' 9 ' )
return ( i - ' 0 ' ) ;
else if ( i > = ' A ' & & i < = ' F ' )
return ( i - ' A ' + 10 ) ;
else
return ( i - ' a ' + 10 ) ;
}
2009-04-01 22:03:56 +00:00
int Q_atoi ( const char * str )
2004-08-21 01:25:48 +00:00
{
int val ;
int sign ;
int c ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
if ( * str = = ' - ' )
{
sign = - 1 ;
str + + ;
}
else
sign = 1 ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
val = 0 ;
//
// check for hex
//
if ( str [ 0 ] = = ' 0 ' & & ( str [ 1 ] = = ' x ' | | str [ 1 ] = = ' X ' ) )
{
str + = 2 ;
while ( 1 )
{
c = * str + + ;
if ( c > = ' 0 ' & & c < = ' 9 ' )
val = ( val < < 4 ) + c - ' 0 ' ;
else if ( c > = ' a ' & & c < = ' f ' )
val = ( val < < 4 ) + c - ' a ' + 10 ;
else if ( c > = ' A ' & & c < = ' F ' )
val = ( val < < 4 ) + c - ' A ' + 10 ;
else
return val * sign ;
}
}
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
//
// check for character
//
if ( str [ 0 ] = = ' \' ' )
{
return sign * str [ 1 ] ;
}
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
//
// assume decimal
//
while ( 1 )
{
c = * str + + ;
if ( c < ' 0 ' | | c > ' 9 ' )
return val * sign ;
val = val * 10 + c - ' 0 ' ;
}
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
return 0 ;
}
2009-04-01 22:03:56 +00:00
float Q_atof ( const char * str )
2004-08-21 01:25:48 +00:00
{
double val ;
int sign ;
int c ;
int decimal , total ;
2005-07-01 19:23:00 +00:00
while ( * str = = ' ' )
str + + ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
if ( * str = = ' - ' )
{
sign = - 1 ;
str + + ;
}
else
sign = 1 ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
val = 0 ;
//
// check for hex
//
if ( str [ 0 ] = = ' 0 ' & & ( str [ 1 ] = = ' x ' | | str [ 1 ] = = ' X ' ) )
{
str + = 2 ;
while ( 1 )
{
c = * str + + ;
if ( c > = ' 0 ' & & c < = ' 9 ' )
val = ( val * 16 ) + c - ' 0 ' ;
else if ( c > = ' a ' & & c < = ' f ' )
val = ( val * 16 ) + c - ' a ' + 10 ;
else if ( c > = ' A ' & & c < = ' F ' )
val = ( val * 16 ) + c - ' A ' + 10 ;
else
return val * sign ;
}
}
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
//
// check for character
//
if ( str [ 0 ] = = ' \' ' )
{
return sign * str [ 1 ] ;
}
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
//
// assume decimal
//
decimal = - 1 ;
total = 0 ;
while ( 1 )
{
c = * str + + ;
if ( c = = ' . ' )
{
decimal = total ;
continue ;
}
if ( c < ' 0 ' | | c > ' 9 ' )
break ;
val = val * 10 + c - ' 0 ' ;
total + + ;
}
if ( decimal = = - 1 )
return val * sign ;
while ( total > decimal )
{
val / = 10 ;
total - - ;
}
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
return val * sign ;
}
2011-10-27 16:16:29 +00:00
/*
attempts to remove leet strange chars from a name
the resulting string is not intended to be visible to humans , but this functions results can be matched against each other .
*/
2014-03-30 08:55:06 +00:00
void deleetstring ( char * result , const char * leet )
2011-10-27 16:16:29 +00:00
{
char * s = result ;
2014-03-30 08:55:06 +00:00
const char * s2 = leet ;
2011-10-27 16:16:29 +00:00
while ( * s2 )
{
2012-09-30 05:52:03 +00:00
if ( * s2 = = ( char ) 0xff )
2011-10-27 16:16:29 +00:00
{
s2 + + ;
continue ;
}
* s = * s2 & ~ 128 ;
s2 + + ;
if ( * s = = ' 3 ' )
* s = ' e ' ;
else if ( * s = = ' 4 ' )
* s = ' a ' ;
else if ( * s = = ' 0 ' )
* s = ' o ' ;
else if ( * s = = ' 1 ' | | * s = = ' 7 ' )
* s = ' l ' ;
else if ( * s > = 18 & & * s < 27 )
* s = * s - 18 + ' 0 ' ;
else if ( * s > = ' A ' & & * s < = ' Z ' )
* s = * s - ' A ' + ' a ' ;
else if ( * s = = ' _ ' | | * s = = ' ' | | * s = = ' ~ ' )
continue ;
s + + ;
}
* s = ' \0 ' ;
}
2004-08-21 01:25:48 +00:00
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
qbyte ORDER FUNCTIONS
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
2006-07-08 22:34:47 +00:00
qboolean bigendian ;
2004-08-21 01:25:48 +00:00
short ( * BigShort ) ( short l ) ;
short ( * LittleShort ) ( short l ) ;
int ( * BigLong ) ( int l ) ;
int ( * LittleLong ) ( int l ) ;
float ( * BigFloat ) ( float l ) ;
float ( * LittleFloat ) ( float l ) ;
short ShortSwap ( short l )
{
qbyte b1 , b2 ;
b1 = l & 255 ;
b2 = ( l > > 8 ) & 255 ;
return ( b1 < < 8 ) + b2 ;
}
short ShortNoSwap ( short l )
{
return l ;
}
int LongSwap ( int l )
{
qbyte b1 , b2 , b3 , b4 ;
b1 = l & 255 ;
b2 = ( l > > 8 ) & 255 ;
b3 = ( l > > 16 ) & 255 ;
b4 = ( l > > 24 ) & 255 ;
return ( ( int ) b1 < < 24 ) + ( ( int ) b2 < < 16 ) + ( ( int ) b3 < < 8 ) + b4 ;
}
int LongNoSwap ( int l )
{
return l ;
}
float FloatSwap ( float f )
{
union
{
float f ;
qbyte b [ 4 ] ;
} dat1 , dat2 ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
dat1 . f = f ;
dat2 . b [ 0 ] = dat1 . b [ 3 ] ;
dat2 . b [ 1 ] = dat1 . b [ 2 ] ;
dat2 . b [ 2 ] = dat1 . b [ 1 ] ;
dat2 . b [ 3 ] = dat1 . b [ 0 ] ;
return dat2 . f ;
}
float FloatNoSwap ( float f )
{
return f ;
}
2006-06-04 01:43:52 +00:00
void COM_SwapLittleShortBlock ( short * s , int size )
{
if ( size < = 0 )
return ;
2006-07-08 22:34:47 +00:00
if ( ! bigendian )
2006-06-04 01:43:52 +00:00
return ;
while ( size )
{
* s = ShortSwap ( * s ) ;
s + + ;
size - - ;
}
}
void COM_CharBias ( signed char * c , int size )
{
if ( size < = 0 )
return ;
while ( size )
{
* c = ( * ( unsigned char * ) c ) - 128 ;
c + + ;
size - - ;
}
}
2004-08-21 01:25:48 +00:00
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
MESSAGE IO FUNCTIONS
Handles qbyte ordering and avoids alignment errors
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
//
// writing functions
//
void MSG_WriteChar ( sizebuf_t * sb , int c )
{
qbyte * buf ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
# ifdef PARANOID
if ( c < - 128 | | c > 127 )
Sys_Error ( " MSG_WriteChar: range error " ) ;
# endif
2005-03-28 00:11:59 +00:00
buf = ( qbyte * ) SZ_GetSpace ( sb , 1 ) ;
2004-08-21 01:25:48 +00:00
buf [ 0 ] = c ;
}
void MSG_WriteByte ( sizebuf_t * sb , int c )
{
qbyte * buf ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
# ifdef PARANOID
if ( c < 0 | | c > 255 )
Sys_Error ( " MSG_WriteByte: range error " ) ;
# endif
2005-03-28 00:11:59 +00:00
buf = ( qbyte * ) SZ_GetSpace ( sb , 1 ) ;
2004-08-21 01:25:48 +00:00
buf [ 0 ] = c ;
}
void MSG_WriteShort ( sizebuf_t * sb , int c )
{
qbyte * buf ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
# ifdef PARANOID
if ( c < ( ( short ) 0x8000 ) | | c > ( short ) 0x7fff )
Sys_Error ( " MSG_WriteShort: range error " ) ;
# endif
2005-03-28 00:11:59 +00:00
buf = ( qbyte * ) SZ_GetSpace ( sb , 2 ) ;
2004-08-21 01:25:48 +00:00
buf [ 0 ] = c & 0xff ;
buf [ 1 ] = c > > 8 ;
}
void MSG_WriteLong ( sizebuf_t * sb , int c )
{
qbyte * buf ;
2006-01-27 02:45:16 +00:00
2005-03-28 00:11:59 +00:00
buf = ( qbyte * ) SZ_GetSpace ( sb , 4 ) ;
2004-08-21 01:25:48 +00:00
buf [ 0 ] = c & 0xff ;
buf [ 1 ] = ( c > > 8 ) & 0xff ;
buf [ 2 ] = ( c > > 16 ) & 0xff ;
buf [ 3 ] = c > > 24 ;
}
void MSG_WriteFloat ( sizebuf_t * sb , float f )
{
union
{
float f ;
int l ;
} dat ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
dat . f = f ;
dat . l = LittleLong ( dat . l ) ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
SZ_Write ( sb , & dat . l , 4 ) ;
}
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
{
if ( ! s )
SZ_Write ( sb , " " , 1 ) ;
else
SZ_Write ( sb , s , Q_strlen ( s ) + 1 ) ;
}
2004-11-13 17:23:03 +00:00
float MSG_FromCoord ( coorddata c , int bytes )
{
switch ( bytes )
{
case 2 : //encode 1/8th precision, giving -4096 to 4096 map sizes
2005-05-17 02:00:13 +00:00
return LittleShort ( c . b2 ) / 8.0f ;
2012-02-27 12:23:15 +00:00
case 3 :
return LittleShort ( c . b2 ) + ( ( ( unsigned char * ) c . b ) [ 2 ] * ( 1 / 255.0 ) ) ; /*FIXME: RMQe uses 255, should be 256*/
2004-11-13 17:23:03 +00:00
case 4 :
2005-05-17 02:00:13 +00:00
return LittleFloat ( c . f ) ;
2004-11-13 17:23:03 +00:00
default :
Sys_Error ( " MSG_ToCoord: not a sane coordsize " ) ;
return 0 ;
}
}
coorddata MSG_ToCoord ( float f , int bytes ) / / return value should be treated as ( char * ) & ret ;
2004-08-21 01:25:48 +00:00
{
2004-11-13 17:23:03 +00:00
coorddata r ;
switch ( bytes )
{
case 2 :
2009-11-15 03:20:17 +00:00
r . b4 = 0 ;
if ( f > = 0 )
r . b2 = LittleShort ( ( short ) ( f * 8 + 0.5f ) ) ;
else
r . b2 = LittleShort ( ( short ) ( f * 8 - 0.5f ) ) ;
break ;
case 4 :
r . f = LittleFloat ( f ) ;
break ;
default :
Sys_Error ( " MSG_ToCoord: not a sane coordsize " ) ;
r . b4 = 0 ;
}
return r ;
}
coorddata MSG_ToAngle ( float f , int bytes ) //return value is NOT byteswapped.
{
coorddata r ;
switch ( bytes )
{
case 1 :
r . b4 = 0 ;
if ( f > = 0 )
r . b [ 0 ] = ( int ) ( f * ( 256.0f / 360.0f ) + 0.5f ) & 255 ;
else
r . b [ 0 ] = ( int ) ( f * ( 256.0f / 360.0f ) - 0.5f ) & 255 ;
break ;
case 2 :
r . b4 = 0 ;
if ( f > = 0 )
r . b2 = LittleShort ( ( int ) ( f * ( 65536.0f / 360.0f ) + 0.5f ) & 65535 ) ;
else
r . b2 = LittleShort ( ( int ) ( f * ( 65536.0f / 360.0f ) - 0.5f ) & 65535 ) ;
2004-11-13 17:23:03 +00:00
break ;
case 4 :
2005-05-17 02:00:13 +00:00
r . f = LittleFloat ( f ) ;
2004-11-13 17:23:03 +00:00
break ;
default :
Sys_Error ( " MSG_ToCoord: not a sane coordsize " ) ;
r . b4 = 0 ;
}
return r ;
2004-08-21 01:25:48 +00:00
}
2004-11-13 17:23:03 +00:00
void MSG_WriteCoord ( sizebuf_t * sb , float f )
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
coorddata i = MSG_ToCoord ( f , sb - > prim . coordsize ) ;
SZ_Write ( sb , ( void * ) & i , sb - > prim . coordsize ) ;
2004-08-21 01:25:48 +00:00
}
2004-11-27 08:16:25 +00:00
void MSG_WriteAngle16 ( sizebuf_t * sb , float f )
2004-08-21 01:25:48 +00:00
{
2009-11-15 03:20:17 +00:00
if ( f > = 0 )
MSG_WriteShort ( sb , ( int ) ( f * ( 65536.0f / 360.0f ) + 0.5f ) & 65535 ) ;
else
MSG_WriteShort ( sb , ( int ) ( f * ( 65536.0f / 360.0f ) - 0.5f ) & 65535 ) ;
2004-08-21 01:25:48 +00:00
}
2005-06-14 04:52:10 +00:00
void MSG_WriteAngle8 ( sizebuf_t * sb , float f )
{
2009-11-15 03:20:17 +00:00
if ( f > = 0 )
MSG_WriteByte ( sb , ( int ) ( f * ( 256.0f / 360.0f ) + 0.5f ) & 255 ) ;
else
MSG_WriteByte ( sb , ( int ) ( f * ( 256.0f / 360.0f ) - 0.5f ) & 255 ) ;
2005-06-14 04:52:10 +00:00
}
2004-08-21 01:25:48 +00:00
2004-11-27 08:16:25 +00:00
void MSG_WriteAngle ( sizebuf_t * sb , float f )
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
if ( sb - > prim . anglesize = = 2 )
2004-11-27 08:16:25 +00:00
MSG_WriteAngle16 ( sb , f ) ;
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
else if ( sb - > prim . anglesize = = 4 )
MSG_WriteFloat ( sb , f ) ;
2004-11-27 08:16:25 +00:00
else
2005-06-14 04:52:10 +00:00
MSG_WriteAngle8 ( sb , f ) ;
2004-08-21 01:25:48 +00:00
}
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
static unsigned int MSG_ReadEntity ( void )
{
unsigned int num ;
num = MSG_ReadShort ( ) ;
if ( num & 0x8000 )
{
num = ( num & 0x7fff ) < < 8 ;
num | = MSG_ReadByte ( ) ;
}
return num ;
}
//we use the high bit of the entity number to state that this is a large entity.
# ifndef CLIENTONLY
unsigned int MSGSV_ReadEntity ( client_t * fromclient )
{
unsigned int num ;
if ( fromclient - > fteprotocolextensions2 & PEXT2_REPLACEMENTDELTAS )
num = MSG_ReadEntity ( ) ;
else
num = ( unsigned short ) ( short ) MSG_ReadEntity ( ) ;
if ( num > = sv . world . max_edicts )
{
Con_Printf ( " client %s sent invalid entity \n " , fromclient - > name ) ;
fromclient - > drop = true ;
return 0 ;
}
return num ;
}
# endif
# ifndef SERVERONLY
unsigned int MSGCL_ReadEntity ( void )
{
unsigned int num ;
if ( cls . fteprotocolextensions2 & PEXT2_REPLACEMENTDELTAS )
num = MSG_ReadEntity ( ) ;
else
num = ( unsigned short ) ( short ) MSG_ReadShort ( ) ;
return num ;
}
//compat for ktx/ezquake's railgun
unsigned int MSGCLF_ReadEntity ( qboolean * flagged )
{
int s ;
* flagged = false ;
if ( cls . fteprotocolextensions2 & PEXT2_REPLACEMENTDELTAS )
return MSG_ReadEntity ( ) ;
else
{
s = MSG_ReadShort ( ) ;
if ( s < 0 )
{
* flagged = true ;
return - 1 - s ;
}
else
return s ;
}
}
# endif
void MSG_WriteEntity ( sizebuf_t * sb , unsigned int entnum )
{
if ( entnum > MAX_EDICTS )
Host_EndGame ( " index %#x is not a valid entity \n " , entnum ) ;
if ( entnum > = 0x8000 )
{
MSG_WriteShort ( sb , ( entnum > > 8 ) | 0x8000 ) ;
MSG_WriteByte ( sb , entnum & 0xff ) ;
}
else
MSG_WriteShort ( sb , entnum ) ;
}
2004-08-21 01:25:48 +00:00
void MSG_WriteDeltaUsercmd ( sizebuf_t * buf , usercmd_t * from , usercmd_t * cmd )
{
int bits ;
//
// send the movement message
//
bits = 0 ;
# ifdef Q2CLIENT
2005-05-26 12:55:34 +00:00
if ( cls . protocol = = CP_QUAKE2 )
2004-08-21 01:25:48 +00:00
{
if ( cmd - > angles [ 0 ] ! = from - > angles [ 0 ] )
bits | = Q2CM_ANGLE1 ;
if ( cmd - > angles [ 1 ] ! = from - > angles [ 1 ] )
bits | = Q2CM_ANGLE2 ;
if ( cmd - > angles [ 2 ] ! = from - > angles [ 2 ] )
bits | = Q2CM_ANGLE3 ;
if ( cmd - > forwardmove ! = from - > forwardmove )
bits | = Q2CM_FORWARD ;
if ( cmd - > sidemove ! = from - > sidemove )
bits | = Q2CM_SIDE ;
if ( cmd - > upmove ! = from - > upmove )
bits | = Q2CM_UP ;
if ( cmd - > buttons ! = from - > buttons )
bits | = Q2CM_BUTTONS ;
if ( cmd - > impulse ! = from - > impulse )
bits | = Q2CM_IMPULSE ;
MSG_WriteByte ( buf , bits ) ;
if ( bits & Q2CM_ANGLE1 )
MSG_WriteShort ( buf , cmd - > angles [ 0 ] ) ;
if ( bits & Q2CM_ANGLE2 )
MSG_WriteShort ( buf , cmd - > angles [ 1 ] ) ;
if ( bits & Q2CM_ANGLE3 )
MSG_WriteShort ( buf , cmd - > angles [ 2 ] ) ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
if ( bits & Q2CM_FORWARD )
MSG_WriteShort ( buf , cmd - > forwardmove ) ;
if ( bits & Q2CM_SIDE )
MSG_WriteShort ( buf , cmd - > sidemove ) ;
if ( bits & Q2CM_UP )
MSG_WriteShort ( buf , cmd - > upmove ) ;
if ( bits & Q2CM_BUTTONS )
MSG_WriteByte ( buf , cmd - > buttons ) ;
if ( bits & Q2CM_IMPULSE )
MSG_WriteByte ( buf , cmd - > impulse ) ;
MSG_WriteByte ( buf , cmd - > msec ) ;
MSG_WriteByte ( buf , cmd - > lightlevel ) ;
}
else
# endif
{
if ( cmd - > angles [ 0 ] ! = from - > angles [ 0 ] )
bits | = CM_ANGLE1 ;
if ( cmd - > angles [ 1 ] ! = from - > angles [ 1 ] )
bits | = CM_ANGLE2 ;
if ( cmd - > angles [ 2 ] ! = from - > angles [ 2 ] )
bits | = CM_ANGLE3 ;
if ( cmd - > forwardmove ! = from - > forwardmove )
bits | = CM_FORWARD ;
if ( cmd - > sidemove ! = from - > sidemove )
bits | = CM_SIDE ;
if ( cmd - > upmove ! = from - > upmove )
bits | = CM_UP ;
if ( cmd - > buttons ! = from - > buttons )
bits | = CM_BUTTONS ;
if ( cmd - > impulse ! = from - > impulse )
bits | = CM_IMPULSE ;
MSG_WriteByte ( buf , bits ) ;
if ( bits & CM_ANGLE1 )
MSG_WriteShort ( buf , cmd - > angles [ 0 ] ) ;
if ( bits & CM_ANGLE2 )
MSG_WriteShort ( buf , cmd - > angles [ 1 ] ) ;
if ( bits & CM_ANGLE3 )
MSG_WriteShort ( buf , cmd - > angles [ 2 ] ) ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
if ( bits & CM_FORWARD )
MSG_WriteShort ( buf , cmd - > forwardmove ) ;
if ( bits & CM_SIDE )
MSG_WriteShort ( buf , cmd - > sidemove ) ;
if ( bits & CM_UP )
MSG_WriteShort ( buf , cmd - > upmove ) ;
if ( bits & CM_BUTTONS )
MSG_WriteByte ( buf , cmd - > buttons ) ;
if ( bits & CM_IMPULSE )
MSG_WriteByte ( buf , cmd - > impulse ) ;
MSG_WriteByte ( buf , cmd - > msec ) ;
}
}
//
// reading functions
//
int msg_readcount ;
qboolean msg_badread ;
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 )
2004-08-21 01:25:48 +00:00
{
msg_readcount = 0 ;
msg_badread = false ;
2004-12-24 08:45:56 +00:00
net_message . currentbit = 0 ;
2005-01-28 04:25:40 +00:00
net_message . packing = SZ_RAWBYTES ;
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
net_message . prim = prim ;
}
void MSG_ChangePrimitives ( struct netprim_s prim )
{
net_message . prim = prim ;
2004-08-21 01:25:48 +00:00
}
int MSG_GetReadCount ( void )
{
return msg_readcount ;
}
2004-12-24 08:45:56 +00:00
/*
= = = = = = = = = = = =
MSG_ReadRawBytes
= = = = = = = = = = = =
*/
static int MSG_ReadRawBytes ( sizebuf_t * msg , int bits )
{
int bitmask = 0 ;
if ( bits < = 8 )
{
bitmask = ( unsigned char ) msg - > data [ msg_readcount ] ;
msg_readcount + + ;
msg - > currentbit + = 8 ;
}
else if ( bits < = 16 )
{
bitmask = ( unsigned short ) ( msg - > data [ msg_readcount ]
+ ( msg - > data [ msg_readcount + 1 ] < < 8 ) ) ;
msg_readcount + = 2 ;
msg - > currentbit + = 16 ;
}
else if ( bits < = 32 )
{
bitmask = msg - > data [ msg_readcount ]
+ ( msg - > data [ msg_readcount + 1 ] < < 8 )
+ ( msg - > data [ msg_readcount + 2 ] < < 16 )
+ ( msg - > data [ msg_readcount + 3 ] < < 24 ) ;
msg_readcount + = 4 ;
msg - > currentbit + = 32 ;
}
return bitmask ;
}
/*
= = = = = = = = = = = =
MSG_ReadRawBits
= = = = = = = = = = = =
*/
static int MSG_ReadRawBits ( sizebuf_t * msg , int bits )
{
int i ;
int val ;
int bitmask = 0 ;
for ( i = 0 ; i < bits ; i + + )
{
val = msg - > data [ msg - > currentbit > > 3 ] > > ( msg - > currentbit & 7 ) ;
msg - > currentbit + + ;
2006-01-27 02:45:16 +00:00
bitmask | = ( val & 1 ) < < i ;
2004-12-24 08:45:56 +00:00
}
return bitmask ;
}
2005-08-10 22:39:56 +00:00
# ifdef HUFFNETWORK
2004-12-24 08:45:56 +00:00
/*
= = = = = = = = = = = =
MSG_ReadHuffBits
= = = = = = = = = = = =
*/
static int MSG_ReadHuffBits ( sizebuf_t * msg , int bits )
{
int i ;
int val ;
int bitmask ;
int remaining = bits & 7 ;
bitmask = MSG_ReadRawBits ( msg , remaining ) ;
2006-01-27 02:45:16 +00:00
2004-12-24 08:45:56 +00:00
for ( i = 0 ; i < bits - remaining ; i + = 8 )
{
val = Huff_GetByte ( msg - > data , & msg - > currentbit ) ;
bitmask | = val < < ( i + remaining ) ;
}
msg_readcount = ( msg - > currentbit > > 3 ) + 1 ;
return bitmask ;
}
2004-12-24 09:10:39 +00:00
# endif
2004-12-24 08:45:56 +00:00
int MSG_ReadBits ( int bits )
{
int bitmask = 0 ;
qboolean extend = false ;
# ifdef PARANOID
if ( ! bits | | bits < - 31 | | bits > 32 )
Host_EndGame ( " MSG_ReadBits: bad bits %i " , bits ) ;
# endif
if ( bits < 0 )
{
bits = - bits ;
extend = true ;
}
switch ( net_message . packing )
{
default :
case SZ_BAD :
Sys_Error ( " MSG_ReadBits: bad net_message.packing " ) ;
break ;
case SZ_RAWBYTES :
bitmask = MSG_ReadRawBytes ( & net_message , bits ) ;
break ;
case SZ_RAWBITS :
bitmask = MSG_ReadRawBits ( & net_message , bits ) ;
break ;
2005-08-10 22:39:56 +00:00
# ifdef HUFFNETWORK
2004-12-24 08:45:56 +00:00
case SZ_HUFFMAN :
bitmask = MSG_ReadHuffBits ( & net_message , bits ) ;
break ;
2004-12-24 09:10:39 +00:00
# endif
2004-12-24 08:45:56 +00:00
}
if ( extend )
{
if ( bitmask & ( 1 < < ( bits - 1 ) ) )
{
bitmask | = ~ ( ( 1 < < bits ) - 1 ) ;
}
}
return bitmask ;
}
2010-07-18 08:42:59 +00:00
void MSG_ReadSkip ( int bytes )
{
if ( net_message . packing ! = SZ_RAWBYTES )
{
while ( bytes > 4 )
{
MSG_ReadBits ( 32 ) ;
bytes - = 4 ;
}
while ( bytes > 0 )
{
MSG_ReadBits ( 8 ) ;
bytes - - ;
}
}
if ( msg_readcount + bytes > net_message . cursize )
{
msg_readcount = net_message . cursize ;
msg_badread = true ;
return ;
}
msg_readcount + = bytes ;
}
2004-08-21 01:25:48 +00:00
// returns -1 and sets msg_badread if no more characters are available
int MSG_ReadChar ( void )
{
int c ;
2004-12-24 08:45:56 +00:00
if ( net_message . packing ! = SZ_RAWBYTES )
return ( signed char ) MSG_ReadBits ( 8 ) ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
if ( msg_readcount + 1 > net_message . cursize )
{
msg_badread = true ;
return - 1 ;
}
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
c = ( signed char ) net_message . data [ msg_readcount ] ;
msg_readcount + + ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
return c ;
}
int MSG_ReadByte ( void )
{
2004-12-24 08:45:56 +00:00
unsigned char c ;
if ( net_message . packing ! = SZ_RAWBYTES )
return ( unsigned char ) MSG_ReadBits ( 8 ) ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
if ( msg_readcount + 1 > net_message . cursize )
{
msg_badread = true ;
return - 1 ;
}
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
c = ( unsigned char ) net_message . data [ msg_readcount ] ;
msg_readcount + + ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
return c ;
}
int MSG_ReadShort ( void )
{
int c ;
2004-12-24 08:45:56 +00:00
if ( net_message . packing ! = SZ_RAWBYTES )
return ( short ) MSG_ReadBits ( 16 ) ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
if ( msg_readcount + 2 > net_message . cursize )
{
msg_badread = true ;
return - 1 ;
}
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
c = ( short ) ( net_message . data [ msg_readcount ]
+ ( net_message . data [ msg_readcount + 1 ] < < 8 ) ) ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
msg_readcount + = 2 ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
return c ;
}
int MSG_ReadLong ( void )
{
int c ;
2004-12-24 08:45:56 +00:00
if ( net_message . packing ! = SZ_RAWBYTES )
return ( int ) MSG_ReadBits ( 32 ) ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
if ( msg_readcount + 4 > net_message . cursize )
{
msg_badread = true ;
return - 1 ;
}
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
c = net_message . data [ msg_readcount ]
+ ( net_message . data [ msg_readcount + 1 ] < < 8 )
+ ( net_message . data [ msg_readcount + 2 ] < < 16 )
+ ( net_message . data [ msg_readcount + 3 ] < < 24 ) ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
msg_readcount + = 4 ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
return c ;
}
float MSG_ReadFloat ( void )
{
union
{
qbyte b [ 4 ] ;
float f ;
int l ;
} dat ;
2004-12-24 08:45:56 +00:00
if ( net_message . packing ! = SZ_RAWBYTES )
{
dat . l = MSG_ReadBits ( 32 ) ;
return dat . f ;
}
2004-08-21 01:25:48 +00:00
if ( msg_readcount + 4 > net_message . cursize )
{
msg_badread = true ;
return - 1 ;
}
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
dat . b [ 0 ] = net_message . data [ msg_readcount ] ;
dat . b [ 1 ] = net_message . data [ msg_readcount + 1 ] ;
dat . b [ 2 ] = net_message . data [ msg_readcount + 2 ] ;
dat . b [ 3 ] = net_message . data [ msg_readcount + 3 ] ;
msg_readcount + = 4 ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
dat . l = LittleLong ( dat . l ) ;
2006-01-27 02:45:16 +00:00
return dat . f ;
2004-08-21 01:25:48 +00:00
}
2014-03-30 08:55:06 +00:00
char * MSG_ReadStringBuffer ( char * out , size_t outsize )
{
int l , c ;
l = 0 ;
do
{
c = MSG_ReadChar ( ) ;
if ( msg_badread | | c = = 0 )
break ;
out [ l ] = c ;
l + + ;
} while ( l < outsize - 1 ) ;
out [ l ] = 0 ;
return out ;
}
2004-08-21 01:25:48 +00:00
char * MSG_ReadString ( void )
{
2014-02-14 09:59:32 +00:00
static char string [ 8192 ] ;
2004-08-21 01:25:48 +00:00
int l , c ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
l = 0 ;
do
{
c = MSG_ReadChar ( ) ;
2007-05-25 22:16:29 +00:00
if ( msg_badread | | c = = 0 )
2004-08-21 01:25:48 +00:00
break ;
string [ l ] = c ;
l + + ;
} while ( l < sizeof ( string ) - 1 ) ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
string [ l ] = 0 ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
return string ;
}
char * MSG_ReadStringLine ( void )
{
static char string [ 2048 ] ;
int l , c ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
l = 0 ;
do
{
c = MSG_ReadChar ( ) ;
2007-05-25 22:16:29 +00:00
if ( msg_badread | | c = = 0 | | c = = ' \n ' )
2004-08-21 01:25:48 +00:00
break ;
string [ l ] = c ;
l + + ;
} while ( l < sizeof ( string ) - 1 ) ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
string [ l ] = 0 ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
return string ;
}
float MSG_ReadCoord ( void )
{
2006-03-04 20:43:48 +00:00
coorddata c = { { 0 } } ;
2010-11-20 22:01:16 +00:00
if ( ! net_message . prim . coordsize )
net_message . prim . coordsize = 2 ;
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
MSG_ReadData ( & c , net_message . prim . coordsize ) ;
return MSG_FromCoord ( c , net_message . prim . coordsize ) ;
2004-08-21 01:25:48 +00:00
}
void MSG_ReadPos ( vec3_t pos )
{
2004-11-27 08:16:25 +00:00
pos [ 0 ] = MSG_ReadCoord ( ) ;
pos [ 1 ] = MSG_ReadCoord ( ) ;
pos [ 2 ] = MSG_ReadCoord ( ) ;
2004-08-21 01:25:48 +00:00
}
2010-08-12 09:04:05 +00:00
# if defined(Q2SERVER) || !defined(SERVERONLY)
2004-08-21 01:25:48 +00:00
# define Q2NUMVERTEXNORMALS 162
vec3_t bytedirs [ Q2NUMVERTEXNORMALS ] =
{
# include "../client/q2anorms.h"
} ;
2010-08-12 09:04:05 +00:00
# endif
# ifndef SERVERONLY
2004-08-21 01:25:48 +00:00
void MSG_ReadDir ( vec3_t dir )
{
int b ;
b = MSG_ReadByte ( ) ;
if ( b > = Q2NUMVERTEXNORMALS )
2006-02-22 23:45:15 +00:00
{
CL_DumpPacket ( ) ;
2004-08-21 01:25:48 +00:00
Host_EndGame ( " MSG_ReadDir: out of range " ) ;
2006-02-22 23:45:15 +00:00
}
2004-08-21 01:25:48 +00:00
VectorCopy ( bytedirs [ b ] , dir ) ;
}
2010-08-12 09:04:05 +00:00
# endif
2013-07-14 12:22:51 +00:00
# if 1 //def Q2SERVER
2004-08-21 01:25:48 +00:00
void MSG_WriteDir ( sizebuf_t * sb , vec3_t dir )
{
int i , best ;
float d , bestd ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
if ( ! dir )
{
MSG_WriteByte ( sb , 0 ) ;
return ;
}
bestd = 0 ;
best = 0 ;
for ( i = 0 ; i < Q2NUMVERTEXNORMALS ; i + + )
{
d = DotProduct ( dir , bytedirs [ i ] ) ;
if ( d > bestd )
{
bestd = d ;
best = i ;
}
}
MSG_WriteByte ( sb , best ) ;
}
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
# endif
2004-08-21 01:25:48 +00:00
float MSG_ReadAngle16 ( void )
{
return MSG_ReadShort ( ) * ( 360.0 / 65536 ) ;
}
2004-11-27 08:16:25 +00:00
float MSG_ReadAngle ( void )
{
2010-11-20 22:01:16 +00:00
if ( ! net_message . prim . anglesize )
net_message . prim . anglesize = 1 ;
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
switch ( net_message . prim . anglesize )
{
case 2 :
2004-11-27 08:16:25 +00:00
return MSG_ReadAngle16 ( ) ;
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
case 4 :
return MSG_ReadFloat ( ) ;
case 1 :
return MSG_ReadChar ( ) * ( 360.0 / 256 ) ;
default :
Host_Error ( " Bad angle size \n " ) ;
return 0 ;
}
2004-11-27 08:16:25 +00:00
}
2004-08-21 01:25:48 +00:00
void MSG_ReadDeltaUsercmd ( usercmd_t * from , usercmd_t * move )
{
int bits ;
memcpy ( move , from , sizeof ( * move ) ) ;
bits = MSG_ReadByte ( ) ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
// read current angles
if ( bits & CM_ANGLE1 )
move - > angles [ 0 ] = MSG_ReadShort ( ) ;
if ( bits & CM_ANGLE2 )
move - > angles [ 1 ] = MSG_ReadShort ( ) ;
if ( bits & CM_ANGLE3 )
move - > angles [ 2 ] = MSG_ReadShort ( ) ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
// read movement
if ( bits & CM_FORWARD )
move - > forwardmove = MSG_ReadShort ( ) ;
if ( bits & CM_SIDE )
move - > sidemove = MSG_ReadShort ( ) ;
if ( bits & CM_UP )
move - > upmove = MSG_ReadShort ( ) ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
// read buttons
if ( bits & CM_BUTTONS )
move - > buttons = MSG_ReadByte ( ) ;
if ( bits & CM_IMPULSE )
move - > impulse = MSG_ReadByte ( ) ;
// read time to run command
move - > msec = MSG_ReadByte ( ) ;
}
void MSGQ2_ReadDeltaUsercmd ( usercmd_t * from , usercmd_t * move )
{
int bits ;
memcpy ( move , from , sizeof ( * move ) ) ;
bits = MSG_ReadByte ( ) ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
// read current angles
if ( bits & Q2CM_ANGLE1 )
move - > angles [ 0 ] = MSG_ReadShort ( ) ;
if ( bits & Q2CM_ANGLE2 )
move - > angles [ 1 ] = MSG_ReadShort ( ) ;
if ( bits & Q2CM_ANGLE3 )
move - > angles [ 2 ] = MSG_ReadShort ( ) ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
// read movement
if ( bits & Q2CM_FORWARD )
move - > forwardmove = MSG_ReadShort ( ) ;
if ( bits & Q2CM_SIDE )
move - > sidemove = MSG_ReadShort ( ) ;
if ( bits & Q2CM_UP )
move - > upmove = MSG_ReadShort ( ) ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
// read buttons
if ( bits & Q2CM_BUTTONS )
move - > buttons = MSG_ReadByte ( ) ;
2011-06-29 18:39:11 +00:00
move - > buttons_compat = move - > buttons & 0xff ;
2004-08-21 01:25:48 +00:00
if ( bits & Q2CM_IMPULSE )
move - > impulse = MSG_ReadByte ( ) ;
// read time to run command
2013-09-29 17:11:47 +00:00
move - > msec_compat = move - > msec = MSG_ReadByte ( ) ;
2004-08-21 01:25:48 +00:00
move - > lightlevel = MSG_ReadByte ( ) ;
}
void MSG_ReadData ( void * data , int len )
{
int i ;
for ( i = 0 ; i < len ; i + + )
( ( qbyte * ) data ) [ i ] = MSG_ReadByte ( ) ;
}
//===========================================================================
void SZ_Clear ( sizebuf_t * buf )
{
buf - > cursize = 0 ;
buf - > overflowed = false ;
}
void * SZ_GetSpace ( sizebuf_t * buf , int length )
{
void * data ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
if ( buf - > cursize + length > buf - > maxsize )
{
if ( ! buf - > allowoverflow )
Sys_Error ( " SZ_GetSpace: overflow without allowoverflow set (%d) " , buf - > maxsize ) ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
if ( length > buf - > maxsize )
Sys_Error ( " SZ_GetSpace: %i is > full buffer size " , length ) ;
2006-01-27 02:45:16 +00:00
2007-07-23 10:59:48 +00:00
Sys_Printf ( " SZ_GetSpace: overflow (%i+%i bytes of %i) \n " , buf - > cursize , length , buf - > maxsize ) ; // because Con_Printf may be redirected
2006-01-27 02:45:16 +00:00
SZ_Clear ( buf ) ;
2004-08-21 01:25:48 +00:00
buf - > overflowed = true ;
}
data = buf - > data + buf - > cursize ;
buf - > cursize + = length ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
return data ;
}
void SZ_Write ( sizebuf_t * buf , const void * data , int length )
{
2006-01-27 02:45:16 +00:00
Q_memcpy ( SZ_GetSpace ( buf , length ) , data , length ) ;
2004-08-21 01:25:48 +00:00
}
void SZ_Print ( sizebuf_t * buf , const char * data )
{
int len ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
len = Q_strlen ( data ) + 1 ;
if ( ! buf - > cursize | | buf - > data [ buf - > cursize - 1 ] )
Q_memcpy ( ( qbyte * ) SZ_GetSpace ( buf , len ) , data , len ) ; // no trailing 0
else
{
qbyte * msg ;
2005-03-28 00:11:59 +00:00
msg = ( qbyte * ) SZ_GetSpace ( buf , len - 1 ) ;
2004-08-21 01:25:48 +00:00
if ( msg = = buf - > data ) //whoops. SZ_GetSpace can return buf->data if it overflowed.
msg + + ;
Q_memcpy ( msg - 1 , data , len ) ; // write over trailing 0
}
}
//============================================================================
2014-10-05 20:04:11 +00:00
char * COM_TrimString ( char * str , char * buffer , int buffersize )
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
{
int i ;
while ( * str < = ' ' & & * str > ' \0 ' )
str + + ;
2014-10-05 20:04:11 +00:00
for ( i = 0 ; i < buffersize - 1 ; i + + )
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
{
if ( * str < = ' ' )
break ;
buffer [ i ] = * str + + ;
}
buffer [ i ] = ' \0 ' ;
return buffer ;
}
2004-08-21 01:25:48 +00:00
/*
= = = = = = = = = = = =
COM_SkipPath
= = = = = = = = = = = =
*/
2009-04-01 22:03:56 +00:00
char * COM_SkipPath ( const char * pathname )
2004-08-21 01:25:48 +00:00
{
2009-04-01 22:03:56 +00:00
const char * last ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
last = pathname ;
while ( * pathname )
{
2012-11-27 03:23:19 +00:00
if ( * pathname = = ' / ' | | * pathname = = ' \\ ' )
2004-08-21 01:25:48 +00:00
last = pathname + 1 ;
pathname + + ;
}
2009-04-01 22:03:56 +00:00
return ( char * ) last ;
2004-08-21 01:25:48 +00:00
}
/*
= = = = = = = = = = = =
COM_StripExtension
= = = = = = = = = = = =
*/
2014-04-24 01:53:01 +00:00
void QDECL COM_StripExtension ( const char * in , char * out , int outlen )
2004-08-21 01:25:48 +00:00
{
2005-07-25 13:23:42 +00:00
char * s ;
2006-01-27 02:45:16 +00:00
2009-04-01 22:03:56 +00:00
if ( out ! = in ) //optimisation, most calls use the same buffer
2006-03-11 03:12:10 +00:00
Q_strncpyz ( out , in , outlen ) ;
2005-07-25 13:23:42 +00:00
s = out + strlen ( out ) ;
while ( * s ! = ' / ' & & s ! = out )
{
if ( * s = = ' . ' )
2005-08-03 23:14:59 +00:00
{
2005-07-25 13:23:42 +00:00
* s = 0 ;
2005-08-03 23:14:59 +00:00
break ;
}
2005-07-25 13:23:42 +00:00
s - - ;
}
2004-08-21 01:25:48 +00:00
}
2009-01-14 16:08:57 +00:00
void COM_StripAllExtensions ( char * in , char * out , int outlen )
{
char * s ;
if ( out ! = in )
Q_strncpyz ( out , in , outlen ) ;
s = out + strlen ( out ) ;
while ( * s ! = ' / ' & & s ! = out )
{
if ( * s = = ' . ' )
{
* s = 0 ;
}
s - - ;
}
}
2004-08-21 01:25:48 +00:00
/*
= = = = = = = = = = = =
COM_FileExtension
= = = = = = = = = = = =
*/
2014-10-05 20:04:11 +00:00
char * COM_FileExtension ( const char * in , char * result , size_t sizeofresult )
2004-08-21 01:25:48 +00:00
{
int i ;
2012-02-12 05:18:31 +00:00
const char * dot ;
2004-08-21 01:25:48 +00:00
2012-01-28 10:30:44 +00:00
for ( dot = in + strlen ( in ) ; dot > = in & & * dot ! = ' . ' ; dot - - )
;
if ( dot < in )
2014-10-05 20:04:11 +00:00
{
* result = 0 ;
return result ;
}
2012-01-28 10:30:44 +00:00
in = dot ;
2004-08-21 01:25:48 +00:00
in + + ;
2014-10-05 20:04:11 +00:00
for ( i = 0 ; i < sizeofresult - 1 & & * in ; i + + , in + + )
result [ i ] = * in ;
result [ i ] = 0 ;
return result ;
2004-08-21 01:25:48 +00:00
}
2005-03-18 06:13:36 +00:00
//Quake 2's tank model has a borked skin (or two).
void COM_CleanUpPath ( char * str )
{
char * dots ;
char * slash ;
int critisize = 0 ;
for ( dots = str ; * dots ; dots + + )
{
if ( * dots > = ' A ' & & * dots < = ' Z ' )
{
* dots = * dots - ' A ' + ' a ' ;
critisize = 1 ;
}
else if ( * dots = = ' \\ ' )
{
* dots = ' / ' ;
critisize = 2 ;
}
}
2005-03-28 00:11:59 +00:00
while ( ( dots = strstr ( str , " .. " ) ) )
2005-03-18 06:13:36 +00:00
{
2012-01-28 10:30:44 +00:00
critisize = 0 ;
2005-03-18 06:13:36 +00:00
for ( slash = dots - 2 ; slash > = str ; slash - - )
{
if ( * slash = = ' / ' )
{
memmove ( slash , dots + 2 , strlen ( dots + 2 ) + 1 ) ;
critisize = 3 ;
break ;
}
}
2012-01-28 10:30:44 +00:00
if ( critisize ! = 3 )
{
memmove ( dots , dots + 2 , strlen ( dots + 2 ) + 1 ) ;
critisize = 3 ;
}
2005-03-18 06:13:36 +00:00
}
while ( * str = = ' / ' )
{
memmove ( str , str + 1 , strlen ( str + 1 ) + 1 ) ;
critisize = 4 ;
}
2005-08-26 23:55:09 +00:00
/* if(critisize)
2005-03-18 06:13:36 +00:00
{
if ( critisize = = 1 ) //not a biggy, so not red.
Con_Printf ( " Please fix file case on your files \n " ) ;
else if ( critisize = = 2 ) //you're evil.
Con_Printf ( " ^1NEVER use backslash in a quake filename (we like portability) \n " ) ;
else if ( critisize = = 3 ) //compleatly stupid. The main reason why this function exists. Quake2 does it!
Con_Printf ( " You realise that relative paths are a waste of space? \n " ) ;
else if ( critisize = = 4 ) //AAAAHHHHH! (consider sys_error instead)
Con_Printf ( " ^1AAAAAAAHHHH! An absolute path! \n " ) ;
}
2005-08-26 23:55:09 +00:00
*/
2005-03-18 06:13:36 +00:00
}
2004-08-21 01:25:48 +00:00
/*
= = = = = = = = = = = =
COM_FileBase
= = = = = = = = = = = =
*/
2009-04-01 22:03:56 +00:00
void COM_FileBase ( const char * in , char * out , int outlen )
2004-08-21 01:25:48 +00:00
{
2009-04-01 22:03:56 +00:00
const char * s , * s2 ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
s = in + strlen ( in ) - 1 ;
2006-01-27 02:45:16 +00:00
2007-07-23 10:59:48 +00:00
while ( s > in & & * s ! = ' . ' )
2004-08-21 01:25:48 +00:00
s - - ;
2006-01-27 02:45:16 +00:00
2009-07-18 09:35:38 +00:00
for ( s2 = s ; s2 > in & & * s2 & & * s2 ! = ' / ' ; s2 - - )
2007-07-23 10:59:48 +00:00
;
2004-08-21 01:25:48 +00:00
if ( s - s2 < 2 )
2006-09-17 00:59:22 +00:00
{
if ( s = = s2 )
Q_strncpyz ( out , in , outlen ) ;
else
Q_strncpyz ( out , " ?model? " , outlen ) ;
}
2004-08-21 01:25:48 +00:00
else
{
s - - ;
2006-03-11 03:12:10 +00:00
outlen - - ;
if ( outlen > s - s2 )
outlen = s - s2 ;
Q_strncpyS ( out , s2 + 1 , outlen ) ;
out [ outlen ] = 0 ;
2004-08-21 01:25:48 +00:00
}
}
/*
= = = = = = = = = = = = = = = = = =
COM_DefaultExtension
= = = = = = = = = = = = = = = = = =
*/
2006-03-11 03:12:10 +00:00
void COM_DefaultExtension ( char * path , char * extension , int maxlen )
2004-08-21 01:25:48 +00:00
{
char * src ;
//
// if path doesn't have a .EXT, append extension
// (extension should include the .)
//
src = path + strlen ( path ) - 1 ;
while ( * src ! = ' / ' & & src ! = path )
{
if ( * src = = ' . ' )
return ; // it has an extension
src - - ;
}
2009-11-04 21:16:50 +00:00
if ( * extension ! = ' . ' )
Q_strncatz ( path , " . " , maxlen ) ;
2006-03-11 03:12:10 +00:00
Q_strncatz ( path , extension , maxlen ) ;
2004-08-21 01:25:48 +00:00
}
2014-04-27 23:16:07 +00:00
//adds .ext only if it isn't already present (either case).
//extension *must* contain a leading . as this is really a requiresuffix rather than an actual extension
//returns false if truncated. will otherwise still succeed.
qboolean COM_RequireExtension ( char * path , char * extension , int maxlen )
{
qboolean okay = true ;
int plen = strlen ( path ) ;
int elen = strlen ( extension ) ;
//check if its aready suffixed
if ( plen > = elen )
{
if ( ! Q_strcasecmp ( path + plen - elen , extension ) )
return okay ;
}
2007-06-20 00:02:54 +00:00
2014-04-27 23:16:07 +00:00
//truncate if required
if ( plen + 1 + elen > maxlen )
{
if ( elen + 1 > maxlen )
Sys_Error ( " extension longer than path buffer " ) ;
okay = false ;
plen = maxlen - 1 + elen ;
}
//do the copy
while ( * extension )
path [ plen + + ] = * extension + + ;
path [ plen ] = 0 ;
return okay ;
}
2007-06-20 00:02:54 +00:00
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
//errors:
//1 sequence error
//2 over-long
//3 invalid unicode char
//4 invalid utf-16 lead/high surrogate
//5 invalid utf-16 tail/low surrogate
2013-03-12 22:35:33 +00:00
unsigned int utf8_decode ( int * error , const void * in , char * * out )
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
{
//uc is the output unicode char
unsigned int uc = 0xfffdu ; //replacement character
//l is the length
unsigned int l = 1 ;
const unsigned char * str = in ;
if ( ( * str & 0xe0 ) = = 0xc0 )
{
if ( ( str [ 1 ] & 0xc0 ) = = 0x80 )
{
l = 2 ;
uc = ( ( str [ 0 ] & 0x1f ) < < 6 ) | ( str [ 1 ] & 0x3f ) ;
2013-05-03 04:28:08 +00:00
if ( ! uc | | uc > = ( 1u < < 7 ) ) //allow modified utf-8
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
* error = 0 ;
else
* error = 2 ;
}
else * error = 1 ;
}
else if ( ( * str & 0xf0 ) = = 0xe0 )
{
if ( ( str [ 1 ] & 0xc0 ) = = 0x80 & & ( str [ 2 ] & 0xc0 ) = = 0x80 )
{
l = 3 ;
uc = ( ( str [ 0 ] & 0x0f ) < < 12 ) | ( ( str [ 1 ] & 0x3f ) < < 6 ) | ( ( str [ 2 ] & 0x3f ) < < 0 ) ;
if ( uc > = ( 1u < < 11 ) )
* error = 0 ;
else
* error = 2 ;
}
else * error = 1 ;
}
else if ( ( * str & 0xf8 ) = = 0xf0 )
{
if ( ( str [ 1 ] & 0xc0 ) = = 0x80 & & ( str [ 2 ] & 0xc0 ) = = 0x80 & & ( str [ 3 ] & 0xc0 ) = = 0x80 )
{
l = 4 ;
uc = ( ( str [ 0 ] & 0x07 ) < < 18 ) | ( ( str [ 1 ] & 0x3f ) < < 12 ) | ( ( str [ 2 ] & 0x3f ) < < 6 ) | ( ( str [ 3 ] & 0x3f ) < < 0 ) ;
if ( uc > = ( 1u < < 16 ) )
* error = 0 ;
else
* error = 2 ;
}
else * error = 1 ;
}
else if ( ( * str & 0xfc ) = = 0xf8 )
{
if ( ( str [ 1 ] & 0xc0 ) = = 0x80 & & ( str [ 2 ] & 0xc0 ) = = 0x80 & & ( str [ 3 ] & 0xc0 ) = = 0x80 & & ( str [ 4 ] & 0xc0 ) = = 0x80 )
{
l = 5 ;
uc = ( ( str [ 0 ] & 0x03 ) < < 24 ) | ( ( str [ 1 ] & 0x3f ) < < 18 ) | ( ( str [ 2 ] & 0x3f ) < < 12 ) | ( ( str [ 3 ] & 0x3f ) < < 6 ) | ( ( str [ 4 ] & 0x3f ) < < 0 ) ;
if ( uc > = ( 1u < < 21 ) )
* error = 0 ;
else
* error = 2 ;
}
else * error = 1 ;
}
else if ( ( * str & 0xfe ) = = 0xfc )
{
//six bytes
if ( ( str [ 1 ] & 0xc0 ) = = 0x80 & & ( str [ 2 ] & 0xc0 ) = = 0x80 & & ( str [ 3 ] & 0xc0 ) = = 0x80 & & ( str [ 4 ] & 0xc0 ) = = 0x80 )
{
l = 6 ;
uc = ( ( str [ 0 ] & 0x01 ) < < 30 ) | ( ( str [ 1 ] & 0x3f ) < < 24 ) | ( ( str [ 2 ] & 0x3f ) < < 18 ) | ( ( str [ 3 ] & 0x3f ) < < 12 ) | ( ( str [ 4 ] & 0x3f ) < < 6 ) | ( ( str [ 5 ] & 0x3f ) < < 0 ) ;
if ( uc > = ( 1u < < 26 ) )
* error = 0 ;
else
* error = 2 ;
}
else * error = 1 ;
}
//0xfe and 0xff, while plausable leading bytes, are not permitted.
#if 0
else if ( ( * str & 0xff ) = = 0xfe )
{
if ( ( str [ 1 ] & 0xc0 ) = = 0x80 & & ( str [ 2 ] & 0xc0 ) = = 0x80 & & ( str [ 3 ] & 0xc0 ) = = 0x80 & & ( str [ 4 ] & 0xc0 ) = = 0x80 )
{
l = 7 ;
uc = 0 | ( ( str [ 1 ] & 0x3f ) < < 30 ) | ( ( str [ 2 ] & 0x3f ) < < 24 ) | ( ( str [ 3 ] & 0x3f ) < < 18 ) | ( ( str [ 4 ] & 0x3f ) < < 12 ) | ( ( str [ 5 ] & 0x3f ) < < 6 ) | ( ( str [ 6 ] & 0x3f ) < < 0 ) ;
if ( uc > = ( 1u < < 31 ) )
* error = 0 ;
else
* error = 2 ;
}
else * error = 1 ;
}
else if ( ( * str & 0xff ) = = 0xff )
{
if ( ( str [ 1 ] & 0xc0 ) = = 0x80 & & ( str [ 2 ] & 0xc0 ) = = 0x80 & & ( str [ 3 ] & 0xc0 ) = = 0x80 & & ( str [ 4 ] & 0xc0 ) = = 0x80 )
{
l = 8 ;
uc = 0 | ( ( str [ 1 ] & 0x3f ) < < 36 ) | ( ( str [ 2 ] & 0x3f ) < < 30 ) | ( ( str [ 3 ] & 0x3f ) < < 24 ) | ( ( str [ 4 ] & 0x3f ) < < 18 ) | ( ( str [ 5 ] & 0x3f ) < < 12 ) | ( ( str [ 6 ] & 0x3f ) < < 6 ) | ( ( str [ 7 ] & 0x3f ) < < 0 ) ;
if ( uc > = ( 1llu < < 36 ) )
* error = false ;
else
* error = 2 ;
}
else * error = 1 ;
}
# endif
else if ( * str & 0x80 )
{
//sequence error
* error = 1 ;
uc = 0xe000u + * str ;
}
else
{
//ascii char
* error = 0 ;
uc = * str ;
}
* out = ( void * ) ( str + l ) ;
if ( ! * error )
{
//try to deal with surrogates by decoding the low if we see a high.
if ( uc > = 0xd800u & & uc < 0xdc00u )
{
2013-03-12 22:38:42 +00:00
# if 1
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
//cesu-8
2013-03-12 22:38:42 +00:00
char * lowend ;
unsigned int lowsur = utf8_decode ( error , str + l , & lowend ) ;
if ( * error = = 4 )
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
{
* out = lowend ;
2013-12-29 22:48:28 +00:00
uc = ( ( ( uc & 0x3ffu ) < < 10 ) | ( lowsur & 0x3ffu ) ) + 0x10000 ;
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
* error = false ;
}
else
# endif
{
2013-03-12 22:38:42 +00:00
* error = 3 ; //bad - lead surrogate without tail.
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
}
}
2013-03-12 22:38:42 +00:00
if ( uc > = 0xdc00u & & uc < 0xe000u )
* error = 4 ; //bad - tail surrogate
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
//these are meant to be illegal too
2013-11-29 14:36:47 +00:00
if ( uc = = 0xfffeu | | uc = = 0xffffu | | uc > 0x10ffffu )
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
* error = 2 ; //illegal code
}
return uc ;
}
2013-05-03 04:28:08 +00:00
2014-01-13 02:42:25 +00:00
unsigned int unicode_decode ( int * error , const void * in , char * * out , qboolean markup )
2013-05-03 04:28:08 +00:00
{
unsigned int charcode ;
2014-01-13 02:42:25 +00:00
if ( markup & & ( ( char * ) in ) [ 0 ] = = ' ^ ' & & ( ( char * ) in ) [ 1 ] = = ' U ' & & ishexcode ( ( ( char * ) in ) [ 2 ] ) & & ishexcode ( ( ( char * ) in ) [ 3 ] ) & & ishexcode ( ( ( char * ) in ) [ 4 ] ) & & ishexcode ( ( ( char * ) in ) [ 5 ] ) )
2013-05-03 04:28:08 +00:00
{
* out = ( char * ) in + 6 ;
charcode = ( dehex ( ( ( char * ) in ) [ 2 ] ) < < 12 ) | ( dehex ( ( ( char * ) in ) [ 2 ] ) < < 8 ) | ( dehex ( ( ( char * ) in ) [ 2 ] ) < < 4 ) | ( dehex ( ( ( char * ) in ) [ 2 ] ) < < 0 ) ;
}
2014-01-13 02:42:25 +00:00
else if ( markup & & ( ( char * ) in ) [ 0 ] = = ' ^ ' & & ( ( char * ) in ) [ 1 ] = = ' { ' )
2013-05-03 04:28:08 +00:00
{
* out = ( char * ) in + 2 ;
charcode = 0 ;
while ( ishexcode ( * * out ) )
{
charcode < < = 4 ;
charcode | = dehex ( * * out ) ;
* out + = 1 ;
}
if ( * * out = = ' } ' )
* out + = 1 ;
}
else if ( com_parseutf8 . ival > 0 )
charcode = utf8_decode ( error , in , out ) ;
else if ( com_parseutf8 . ival )
{
* error = 0 ;
charcode = * ( unsigned char * ) in ; //iso8859-1
* out = ( char * ) in + 1 ;
}
else
{ //quake
* error = 0 ;
charcode = * ( unsigned char * ) in ;
2013-12-29 22:48:28 +00:00
if ( charcode & & charcode ! = ' \n ' & & charcode ! = ' \t ' & & charcode ! = ' \r ' & & ( charcode < ' ' | | charcode > 127 ) )
2013-05-03 04:28:08 +00:00
charcode | = 0xe000 ;
* out = ( char * ) in + 1 ;
}
return charcode ;
}
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
unsigned int utf8_encode ( void * out , unsigned int unicode , int maxlen )
{
unsigned int bcount = 1 ;
unsigned int lim = 0x80 ;
unsigned int shift ;
2013-05-03 04:28:08 +00:00
if ( ! unicode )
{ //modified utf-8 encodes encapsulated nulls as over-long.
bcount = 2 ;
}
else
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
{
2013-05-03 04:28:08 +00:00
while ( unicode > = lim )
{
if ( bcount = = 1 )
lim < < = 4 ;
else if ( bcount < 7 )
lim < < = 5 ;
else
lim < < = 6 ;
bcount + + ;
}
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
}
//error if needed
if ( maxlen < bcount )
return 0 ;
//output it.
if ( bcount = = 1 )
2013-03-12 22:30:47 +00:00
{
* ( ( unsigned char * ) out ) = ( unsigned char ) ( unicode & 0x7f ) ;
out = ( char * ) out + 1 ;
}
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
else
{
shift = bcount * 6 ;
shift = shift - 6 ;
2014-02-07 08:38:40 +00:00
* ( ( unsigned char * ) out ) = ( unsigned char ) ( ( unicode > > shift ) & ( 0x0000007f > > bcount ) ) | ( ( 0xffffff00 > > bcount ) & 0xff ) ;
2013-03-12 22:30:47 +00:00
out = ( char * ) out + 1 ;
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
do
{
shift = shift - 6 ;
2013-03-12 22:38:20 +00:00
* ( ( unsigned char * ) out ) = ( unsigned char ) ( ( unicode > > shift ) & 0x3f ) | 0x80 ;
2013-03-12 22:30:47 +00:00
out = ( char * ) out + 1 ;
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
}
while ( shift ) ;
}
return bcount ;
}
2014-01-13 02:42:25 +00:00
unsigned int qchar_encode ( char * out , unsigned int unicode , int maxlen , qboolean markup )
2013-03-12 22:44:00 +00:00
{
static const char hex [ 16 ] = { ' 0 ' , ' 1 ' , ' 2 ' , ' 3 ' , ' 4 ' , ' 5 ' , ' 6 ' , ' 7 ' , ' 8 ' , ' 9 ' , ' a ' , ' b ' , ' c ' , ' d ' , ' e ' , ' f ' } ;
2014-01-13 02:42:25 +00:00
//FIXME: is it a bug that we can't distinguish between true ascii and 0xe0XX ?
2013-03-12 22:47:42 +00:00
if ( ( ( unicode > = 32 | | unicode = = ' \n ' | | unicode = = ' \t ' | | unicode = = ' \r ' ) & & unicode < 128 ) | | ( unicode > = 0xe000 & & unicode < = 0xe0ff ) )
2013-03-12 22:44:00 +00:00
{ //quake compatible chars
if ( maxlen < 1 )
return 0 ;
2014-02-07 08:38:40 +00:00
* out + + = unicode & 0xff ;
2013-03-12 22:44:00 +00:00
return 1 ;
}
2014-01-13 02:42:25 +00:00
else if ( ! markup )
{
if ( maxlen < 1 )
return 0 ;
* out + + = ' ? ' ;
return 1 ;
}
2013-03-12 22:44:00 +00:00
else if ( unicode > 0xffff )
{ //chars longer than 16 bits
char * o = out ;
if ( maxlen < 11 )
return 0 ;
* out + + = ' ^ ' ;
* out + + = ' { ' ;
if ( unicode > 0xfffffff )
* out + + = hex [ ( unicode > > 28 ) & 15 ] ;
if ( unicode > 0xffffff )
* out + + = hex [ ( unicode > > 24 ) & 15 ] ;
if ( unicode > 0xfffff )
* out + + = hex [ ( unicode > > 20 ) & 15 ] ;
if ( unicode > 0xffff )
* out + + = hex [ ( unicode > > 16 ) & 15 ] ;
if ( unicode > 0xfff )
* out + + = hex [ ( unicode > > 12 ) & 15 ] ;
if ( unicode > 0xff )
* out + + = hex [ ( unicode > > 8 ) & 15 ] ;
if ( unicode > 0xf )
* out + + = hex [ ( unicode > > 4 ) & 15 ] ;
if ( unicode > 0x0 )
* out + + = hex [ ( unicode > > 0 ) & 15 ] ;
* out + + = ' } ' ;
return out - o ;
}
else
{ //16bit chars
if ( maxlen < 6 )
return 0 ;
* out + + = ' ^ ' ;
* out + + = ' U ' ;
* out + + = hex [ ( unicode > > 12 ) & 15 ] ;
* out + + = hex [ ( unicode > > 8 ) & 15 ] ;
* out + + = hex [ ( unicode > > 4 ) & 15 ] ;
* out + + = hex [ ( unicode > > 0 ) & 15 ] ;
return 6 ;
}
}
2014-01-13 02:42:25 +00:00
unsigned int iso88591_encode ( char * out , unsigned int unicode , int maxlen , qboolean markup )
2013-03-12 22:44:00 +00:00
{
static const char hex [ 16 ] = { ' 0 ' , ' 1 ' , ' 2 ' , ' 3 ' , ' 4 ' , ' 5 ' , ' 6 ' , ' 7 ' , ' 8 ' , ' 9 ' , ' a ' , ' b ' , ' c ' , ' d ' , ' e ' , ' f ' } ;
2014-01-13 02:42:25 +00:00
if ( unicode < 256 | | ( unicode > = 0xe020 & & unicode < 0xe080 ) )
2013-03-12 22:44:00 +00:00
{ //iso8859-1 compatible chars
if ( maxlen < 1 )
return 0 ;
* out + + = unicode ;
return 1 ;
}
2014-01-13 02:42:25 +00:00
else if ( ! markup )
{
if ( maxlen < 1 )
return 0 ;
* out + + = ' ? ' ;
return 1 ;
}
2013-03-12 22:44:00 +00:00
else if ( unicode > 0xffff )
{ //chars longer than 16 bits
char * o = out ;
if ( maxlen < 11 )
return 0 ;
* out + + = ' ^ ' ;
* out + + = ' { ' ;
if ( unicode > 0xfffffff )
* out + + = hex [ ( unicode > > 28 ) & 15 ] ;
if ( unicode > 0xffffff )
* out + + = hex [ ( unicode > > 24 ) & 15 ] ;
if ( unicode > 0xfffff )
* out + + = hex [ ( unicode > > 20 ) & 15 ] ;
if ( unicode > 0xffff )
* out + + = hex [ ( unicode > > 16 ) & 15 ] ;
if ( unicode > 0xfff )
* out + + = hex [ ( unicode > > 12 ) & 15 ] ;
if ( unicode > 0xff )
* out + + = hex [ ( unicode > > 8 ) & 15 ] ;
if ( unicode > 0xf )
* out + + = hex [ ( unicode > > 4 ) & 15 ] ;
if ( unicode > 0x0 )
* out + + = hex [ ( unicode > > 0 ) & 15 ] ;
* out + + = ' } ' ;
return out - o ;
}
else
{ //16bit chars
if ( maxlen < 6 )
return 0 ;
* out + + = ' ^ ' ;
* out + + = ' U ' ;
* out + + = hex [ ( unicode > > 12 ) & 15 ] ;
* out + + = hex [ ( unicode > > 8 ) & 15 ] ;
* out + + = hex [ ( unicode > > 4 ) & 15 ] ;
* out + + = hex [ ( unicode > > 0 ) & 15 ] ;
return 6 ;
}
}
2014-01-13 02:42:25 +00:00
unsigned int unicode_encode ( char * out , unsigned int unicode , int maxlen , qboolean markup )
2013-03-12 22:44:00 +00:00
{
if ( com_parseutf8 . ival > 0 )
return utf8_encode ( out , unicode , maxlen ) ;
else if ( com_parseutf8 . ival )
2014-01-13 02:42:25 +00:00
return iso88591_encode ( out , unicode , maxlen , markup ) ;
2013-03-12 22:44:00 +00:00
else
2014-01-13 02:42:25 +00:00
return qchar_encode ( out , unicode , maxlen , markup ) ;
2013-03-12 22:44:00 +00:00
}
2007-06-20 00:02:54 +00:00
2013-05-03 04:28:08 +00:00
//char-based strlen.
2014-03-30 08:55:06 +00:00
unsigned int unicode_charcount ( const char * in , size_t buffersize , qboolean markup )
2013-05-03 04:28:08 +00:00
{
int error ;
2014-03-30 08:55:06 +00:00
const char * end = in + buffersize ;
2013-05-03 04:28:08 +00:00
int chars = 0 ;
for ( chars = 0 ; in < end & & * in ; chars + = 1 )
{
2014-03-30 08:55:06 +00:00
unicode_decode ( & error , in , ( char * * ) & in , markup ) ;
2013-05-03 04:28:08 +00:00
if ( in > end )
break ; //exceeded buffer size uncleanly
}
return chars ;
}
//handy hacky function.
2014-03-30 08:55:06 +00:00
unsigned int unicode_byteofsfromcharofs ( const char * str , unsigned int charofs , qboolean markup )
2013-05-03 04:28:08 +00:00
{
2014-03-30 08:55:06 +00:00
const char * in = str ;
2013-05-03 04:28:08 +00:00
int error ;
2013-06-23 02:17:02 +00:00
int chars ;
2013-05-03 04:28:08 +00:00
for ( chars = 0 ; * in ; chars + = 1 )
{
if ( chars > = charofs )
return in - str ;
2014-03-30 08:55:06 +00:00
unicode_decode ( & error , in , ( char * * ) & in , markup ) ;
2013-05-03 04:28:08 +00:00
}
2013-06-23 02:17:02 +00:00
return in - str ;
2013-05-03 04:28:08 +00:00
}
//handy hacky function.
2014-03-30 08:55:06 +00:00
unsigned int unicode_charofsfrombyteofs ( const char * str , unsigned int byteofs , qboolean markup )
2013-05-03 04:28:08 +00:00
{
int error ;
2014-03-30 08:55:06 +00:00
const char * end = str + byteofs ;
2013-05-03 04:28:08 +00:00
int chars = 0 ;
for ( chars = 0 ; str < end & & * str ; chars + = 1 )
{
2014-03-30 08:55:06 +00:00
unicode_decode ( & error , str , ( char * * ) & str , markup ) ;
2013-05-03 04:28:08 +00:00
if ( str > end )
break ; //exceeded buffer size uncleanly
}
return chars ;
}
2013-07-31 00:20:16 +00:00
# ifdef FTE_TARGET_WEB
//targets that don't support towupper/towlower...
# define towupper Q_towupper
# define towlower Q_towlower
int towupper ( int c )
{
if ( c < 128 )
return toupper ( c ) ;
return c ;
}
int towlower ( int c )
{
if ( c < 128 )
return tolower ( c ) ;
return c ;
}
# endif
2014-03-30 08:55:06 +00:00
size_t unicode_strtoupper ( const char * in , char * out , size_t outsize , qboolean markup )
2013-05-03 04:28:08 +00:00
{
//warning: towupper is locale-specific (eg: turkish has both I and dotted-I and thus i should transform to dotted-I rather than to I).
//also it can't easily cope with accent prefixes.
int error ;
unsigned int c ;
size_t l = 0 ;
outsize - = 1 ;
while ( * in )
{
2014-03-30 08:55:06 +00:00
c = unicode_decode ( & error , in , ( char * * ) & in , markup ) ;
2013-05-03 04:28:08 +00:00
if ( c > = 0xe020 & & c < = 0xe07f ) //quake-char-aware.
c = towupper ( c & 0x7f ) + ( c & 0xff80 ) ;
else
c = towupper ( c ) ;
2014-01-13 02:42:25 +00:00
l = unicode_encode ( out , c , outsize - l , markup ) ;
2013-05-03 04:28:08 +00:00
out + = l ;
}
* out = 0 ;
return l ;
}
2014-03-30 08:55:06 +00:00
size_t unicode_strtolower ( const char * in , char * out , size_t outsize , qboolean markup )
2013-05-03 04:28:08 +00:00
{
//warning: towlower is locale-specific (eg: turkish has both i and dotless-i and thus I should transform to dotless-i rather than to i).
//also it can't easily cope with accent prefixes.
int error ;
unsigned int c ;
size_t l = 0 ;
outsize - = 1 ;
while ( * in )
{
2014-03-30 08:55:06 +00:00
c = unicode_decode ( & error , in , ( char * * ) & in , markup ) ;
2013-05-03 04:28:08 +00:00
if ( c > = 0xe020 & & c < = 0xe07f ) //quake-char-aware.
c = towlower ( c & 0x7f ) + ( c & 0xff80 ) ;
else
c = towlower ( c ) ;
2014-01-13 02:42:25 +00:00
l = unicode_encode ( out , c , outsize - l , markup ) ;
2013-05-03 04:28:08 +00:00
out + = l ;
}
* out = 0 ;
return l ;
}
2007-06-20 00:02:54 +00:00
///=====================================
2009-03-07 05:05:54 +00:00
// This is the standard RGBI palette used in CGA text mode
consolecolours_t consolecolours [ MAXCONCOLOURS ] = {
{ 0 , 0 , 0 } , // black
{ 0 , 0 , 0.67 } , // blue
{ 0 , 0.67 , 0 } , // green
{ 0 , 0.67 , 0.67 } , // cyan
{ 0.67 , 0 , 0 } , // red
{ 0.67 , 0 , 0.67 } , // magenta
{ 0.67 , 0.33 , 0 } , // brown
{ 0.67 , 0.67 , 0.67 } , // light gray
{ 0.33 , 0.33 , 0.33 } , // dark gray
{ 0.33 , 0.33 , 1 } , // light blue
{ 0.33 , 1 , 0.33 } , // light green
{ 0.33 , 1 , 1 } , // light cyan
{ 1 , 0.33 , 0.33 } , // light red
{ 1 , 0.33 , 1 } , // light magenta
{ 1 , 1 , 0.33 } , // yellow
{ 1 , 1 , 1 } // white
} ;
2007-06-20 00:02:54 +00:00
2009-03-07 05:05:54 +00:00
// This is for remapping the Q3 color codes to character masks, including ^9
conchar_t q3codemasks [ MAXQ3COLOURS ] = {
0x00000000 , // 0, black
0x0c000000 , // 1, red
0x0a000000 , // 2, green
0x0e000000 , // 3, yellow
0x09000000 , // 4, blue
0x0b000000 , // 5, cyan
0x0d000000 , // 6, magenta
0x0f000000 , // 7, white
0x0f100000 , // 8, half-alpha white (BX_COLOREDTEXT)
0x07000000 // 9, "half-intensity" (BX_COLOREDTEXT)
} ;
2007-06-20 00:02:54 +00:00
2012-10-13 00:56:31 +00:00
//Converts a conchar_t string into a char string. returns the null terminator. pass NULL for stop to calc it
char * COM_DeFunString ( conchar_t * str , conchar_t * stop , char * out , int outsize , qboolean ignoreflags )
2007-06-20 00:02:54 +00:00
{
2012-10-13 00:56:31 +00:00
if ( ! stop )
{
for ( stop = str ; * stop ; stop + + )
;
}
# ifdef _DEBUG
if ( ! outsize )
Sys_Error ( " COM_DeFunString given outsize=0 " ) ;
# endif
/*if (ignoreflags)
2007-06-20 00:02:54 +00:00
{
2012-10-13 00:56:31 +00:00
while ( str < stop )
2007-06-20 00:02:54 +00:00
{
if ( ! - - outsize )
break ;
* out + + = ( unsigned char ) ( * str + + & 255 ) ;
}
2012-10-13 00:56:31 +00:00
* out = 0 ;
2007-06-20 00:02:54 +00:00
}
2012-10-13 00:56:31 +00:00
else */
2007-06-20 00:02:54 +00:00
{
int fl , d ;
2012-10-13 00:56:31 +00:00
unsigned int c ;
int prelinkflags = CON_WHITEMASK ; //if used, its already an error.
2007-06-20 00:02:54 +00:00
//FIXME: TEST!
fl = CON_WHITEMASK ;
2012-10-13 00:56:31 +00:00
while ( str < stop )
2007-06-20 00:02:54 +00:00
{
2012-10-13 00:56:31 +00:00
if ( ( * str & CON_HIDDEN ) & & ignoreflags )
{
str + + ;
continue ;
}
if ( * str = = CON_LINKSTART )
{
if ( ! ignoreflags )
{
if ( outsize < = 2 )
break ;
outsize - = 2 ;
* out + + = ' ^ ' ;
* out + + = ' [ ' ;
}
prelinkflags = fl ;
fl = COLOR_RED < < CON_FGSHIFT ;
str + + ;
continue ;
}
else if ( * str = = CON_LINKEND )
{
if ( ! ignoreflags )
{
if ( outsize < = 2 )
break ;
outsize - = 2 ;
* out + + = ' ^ ' ;
* out + + = ' ] ' ;
}
fl = prelinkflags ;
str + + ;
continue ;
}
else if ( ( * str & CON_FLAGSMASK ) ! = fl & & ! ignoreflags )
2007-06-20 00:02:54 +00:00
{
d = fl ^ ( * str & CON_FLAGSMASK ) ;
// if (fl & CON_NONCLEARBG) //not represented.
if ( d & CON_BLINKTEXT )
{
if ( outsize < = 2 )
break ;
outsize - = 2 ;
* out + + = ' ^ ' ;
* out + + = ' b ' ;
}
if ( d & CON_2NDCHARSETTEXT )
{
if ( outsize < = 2 )
break ;
outsize - = 2 ;
* out + + = ' ^ ' ;
* out + + = ' a ' ;
}
if ( d & CON_HALFALPHA )
{
if ( outsize < = 2 )
break ;
outsize - = 2 ;
* out + + = ' ^ ' ;
* out + + = ' h ' ;
}
2009-04-08 08:12:29 +00:00
2007-06-20 00:02:54 +00:00
if ( d & ( CON_FGMASK | CON_BGMASK | CON_NONCLEARBG ) )
{
2012-10-13 00:56:31 +00:00
static char q3 [ 16 ] = { ' 0 ' , 0 , 0 , 0 ,
0 , 0 , 0 , 0 ,
0 , ' 4 ' , ' 2 ' , ' 5 ' ,
' 1 ' , ' 6 ' , ' 3 ' , ' 7 ' } ;
if ( ! ( d & ( CON_BGMASK | CON_NONCLEARBG ) ) & & q3 [ ( * str & CON_FGMASK ) > > CON_FGSHIFT ] & & ! ( ( d | fl ) & CON_HALFALPHA ) )
{
if ( outsize < = 2 )
break ;
outsize - = 2 ;
2007-06-20 00:02:54 +00:00
2012-10-13 00:56:31 +00:00
d = ( * str & CON_FLAGSMASK ) ;
* out + + = ' ^ ' ;
* out + + = q3 [ ( * str & CON_FGMASK ) > > CON_FGSHIFT ] ;
}
2007-06-20 00:02:54 +00:00
else
{
2012-10-13 00:56:31 +00:00
if ( outsize < = 4 )
break ;
outsize - = 4 ;
d = ( * str & CON_FLAGSMASK ) ;
* out + + = ' ^ ' ;
* out + + = ' & ' ;
if ( ( d & CON_FGMASK ) = = CON_WHITEMASK )
* out = ' - ' ;
else
sprintf ( out , " %X " , d > > 24 ) ;
out + + ;
if ( d & CON_NONCLEARBG )
sprintf ( out , " %X " , d > > 28 ) ;
else
* out = ' - ' ;
out + + ;
2007-06-20 00:02:54 +00:00
}
}
fl = ( * str & CON_FLAGSMASK ) ;
}
2012-10-13 00:56:31 +00:00
//don't magically show hidden text
if ( ignoreflags & & ( * str & CON_HIDDEN ) )
continue ;
2014-01-13 02:42:25 +00:00
c = unicode_encode ( out , ( * str + + & CON_CHARMASK ) , outsize - 1 , ! ignoreflags ) ;
2013-03-12 22:44:00 +00:00
if ( ! c )
break ;
outsize - = c ;
out + = c ;
2007-06-20 00:02:54 +00:00
}
2012-10-13 00:56:31 +00:00
* out = 0 ;
2007-06-20 00:02:54 +00:00
}
2012-10-13 00:56:31 +00:00
return out ;
2007-06-20 00:02:54 +00:00
}
2013-06-23 02:17:02 +00:00
static unsigned int koi2wc ( unsigned char uc )
{
static const char koi2wc_table [ 64 ] =
{
0x4e , 0x30 , 0x31 , 0x46 , 0x34 , 0x35 , 0x44 , 0x33 , 0x45 , 0x38 , 0x39 , 0x3a , 0x3b , 0x3c , 0x3d , 0x3e ,
0x3f , 0x4f , 0x40 , 0x41 , 0x42 , 0x43 , 0x36 , 0x32 , 0x4c , 0x4b , 0x37 , 0x48 , 0x4d , 0x49 , 0x47 , 0x4a ,
0x2e , 0x10 , 0x11 , 0x26 , 0x14 , 0x15 , 0x24 , 0x13 , 0x25 , 0x18 , 0x19 , 0x1a , 0x1b , 0x1c , 0x1d , 0x1e ,
0x1f , 0x2f , 0x20 , 0x21 , 0x22 , 0x23 , 0x16 , 0x12 , 0x2c , 0x2b , 0x17 , 0x28 , 0x2d , 0x29 , 0x27 , 0x2a
} ;
if ( uc > = 192 /* && (unsigned char)c <= 255 */ )
return koi2wc_table [ uc - 192 ] + 0x400 ;
else if ( uc = = ' # ' + 128 )
return 0x0451 ; // russian small yo
else if ( uc = = ' 3 ' + 128 )
return 0x0401 ; // russian capital yo
else if ( uc = = ' 4 ' + 128 )
return 0x0404 ; // ukrainian capital round E
else if ( uc = = ' $ ' + 128 )
return 0x0454 ; // ukrainian small round E
else if ( uc = = ' 6 ' + 128 )
return 0x0406 ; // ukrainian capital I
else if ( uc = = ' & ' + 128 )
return 0x0456 ; // ukrainian small i
else if ( uc = = ' 7 ' + 128 )
return 0x0407 ; // ukrainian capital I with two dots
else if ( uc = = ' \' ' + 128 )
return 0x0457 ; // ukrainian small i with two dots
else if ( uc = = ' > ' + 128 )
return 0x040e ; // belarusian Y
else if ( uc = = ' . ' + 128 )
return 0x045e ; // belarusian y
else if ( uc = = ' / ' + 128 )
return 0x042a ; // russian capital hard sign
else
return uc ;
}
2014-06-30 21:57:35 +00:00
enum
{
BIDI_NEUTRAL ,
BIDI_LTR ,
BIDI_RTL ,
} ;
static char * bidi_chartype ;
static unsigned int bidi_charcount ;
//semi-colon delimited tokens
char * COM_ParseStringSetSep ( const char * data , char sep )
{
int c ;
size_t len ;
len = 0 ;
com_token [ 0 ] = 0 ;
if ( data )
for ( ; * data ; )
{
if ( len > = sizeof ( com_token ) - 1 )
{
com_token [ len ] = 0 ;
return ( char * ) data ;
}
c = * data + + ;
if ( c = = ' ; ' )
break ;
com_token [ len + + ] = c ;
}
com_token [ len ] = 0 ;
return ( char * ) data ;
}
2014-08-15 02:20:41 +00:00
void COM_BiDi_Shutdown ( void )
{
bidi_charcount = 0 ;
BZ_Free ( bidi_chartype ) ;
bidi_chartype = NULL ;
}
static void COM_BiDi_Setup ( void )
2014-06-30 21:57:35 +00:00
{
char * file ;
char * line ;
char * end ;
char * tok ;
unsigned int c ;
qofs_t size ;
file = FS_MallocFile ( " bidi.dat " , FS_ROOT , & size ) ;
if ( file )
{
bidi_chartype = file ;
bidi_charcount = size ;
return ;
}
file = FS_MallocFile ( " UnicodeData.txt " , FS_ROOT , NULL ) ;
if ( ! file )
return ;
bidi_charcount = 0xffff ;
bidi_chartype = BZ_Malloc ( bidi_charcount ) ;
if ( ! bidi_chartype )
bidi_charcount = 0 ;
else
{
for ( c = 0 ; c < bidi_charcount ; c + + )
bidi_chartype [ c ] = BIDI_NEUTRAL ;
for ( line = file ; line ; line = end )
{
end = strchr ( line , ' \n ' ) ;
if ( end )
* end + + = 0 ;
tok = COM_ParseStringSetSep ( line , ' ; ' ) ; //number
c = strtoul ( com_token , NULL , 16 ) ;
tok = COM_ParseStringSetSep ( tok , ' ; ' ) ; //name
tok = COM_ParseStringSetSep ( tok , ' ; ' ) ; //class?
tok = COM_ParseStringSetSep ( tok , ' ; ' ) ; //?
tok = COM_ParseStringSetSep ( tok , ' ; ' ) ; //bidi
if ( c < bidi_charcount )
{
if ( ! Q_strcasecmp ( com_token , " R " ) | | ! Q_strcasecmp ( com_token , " AL " ) )
bidi_chartype [ c ] = BIDI_RTL ;
else if ( ! Q_strcasecmp ( com_token , " L " ) )
bidi_chartype [ c ] = BIDI_LTR ;
else
bidi_chartype [ c ] = BIDI_NEUTRAL ;
}
}
//trim
while ( bidi_charcount > 0 & & bidi_chartype [ bidi_charcount - 1 ] = = BIDI_NEUTRAL )
bidi_charcount - - ;
FS_WriteFile ( " bidi.dat " , bidi_chartype , bidi_charcount , FS_ROOT ) ;
}
BZ_Free ( file ) ;
}
//bi-direction text is fun.
//the text is specified in input order. the first in the string is the first entered on the keyboard.
//this makes switching direction mid-line quite awkward. so lets hope you don't do that too often, mmkay?
2014-08-15 02:20:41 +00:00
static void COM_BiDi_Parse ( conchar_t * fte_restrict start , size_t length )
2014-06-30 21:57:35 +00:00
{
char fl [ 2048 ] , next , run , prev , para = BIDI_LTR ;
size_t i , runstart , j , k ;
unsigned int c ;
conchar_t swap ;
if ( ! bidi_charcount | | ! length | | length > sizeof ( fl ) )
return ;
for ( i = 0 ; i < length ; i + + )
{
c = start [ i ] & CON_CHARMASK ;
if ( c > = bidi_charcount )
fl [ i ] = BIDI_NEUTRAL ;
else
fl [ i ] = bidi_chartype [ c ] ;
}
//de-neutralise it
prev = fl [ 0 ] ;
for ( i = 0 ; i < length ; )
{
if ( fl [ i ] = = BIDI_NEUTRAL )
{
next = prev ; //trailing weak chars can just use the first side
for ( runstart = i ; i < length ; i + + )
{
next = fl [ i ] ;
if ( next ! = BIDI_NEUTRAL )
{
i - - ;
break ;
}
}
//this can happen if the only text is neutral
if ( prev = = BIDI_NEUTRAL )
run = next ;
//if the strong cars are the same direction on both side, we can just use that direction
else if ( prev = = next )
run = prev ;
//if the strong chars differ, we revert to the paragraph's direction.
else
run = para ;
while ( runstart < = i )
fl [ runstart + + ] = run ;
i + + ;
}
else
{
prev = fl [ i ] ;
i + + ;
}
}
for ( run = para , runstart = 0 , i = 0 ; i < = length ; i + + )
{
if ( i > = length )
next = para ;
else
next = fl [ i ] ;
if ( next ! = run )
{
if ( run = = BIDI_NEUTRAL )
break ;
if ( run = = BIDI_RTL )
{ //now swap the rtl text
k = ( i - runstart ) / 2 ;
for ( j = 0 ; j < k ; j + + )
{
//FIXME: ( -> ) and vice versa.
swap = start [ runstart + j ] ;
start [ runstart + j ] = start [ i - j - 1 ] ;
start [ i - j - 1 ] = swap ;
}
}
run = next ;
runstart = i ;
}
}
}
2009-07-05 18:45:53 +00:00
//Takes a q3-style fun string, and returns an expanded string-with-flags (actual return value is the null terminator)
//outsize parameter is in _BYTES_ (so sizeof is safe).
2013-03-12 22:44:00 +00:00
conchar_t * COM_ParseFunString ( conchar_t defaultflags , const char * str , conchar_t * out , int outsize , int flags )
2007-06-20 00:02:54 +00:00
{
2009-05-24 10:11:17 +00:00
conchar_t extstack [ 4 ] ;
2007-06-20 00:02:54 +00:00
int extstackdepth = 0 ;
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
unsigned int uc ;
2010-05-01 22:47:47 +00:00
int utf8 = com_parseutf8 . ival ;
2012-10-13 00:56:31 +00:00
conchar_t linkinitflags = CON_WHITEMASK ; /*doesn't need the init, but msvc is stupid*/
2014-10-05 20:04:11 +00:00
qboolean keepmarkup = ! ! ( flags & PFS_KEEPMARKUP ) ;
2012-10-13 00:56:31 +00:00
qboolean linkkeep = keepmarkup ;
2014-10-05 20:04:11 +00:00
qboolean ezquakemess = false ;
2012-10-13 00:56:31 +00:00
conchar_t * linkstart = NULL ;
2007-06-20 00:02:54 +00:00
2009-05-24 10:11:17 +00:00
conchar_t ext ;
2014-06-30 21:57:35 +00:00
conchar_t * oldout = out ;
2009-05-24 10:11:17 +00:00
2014-10-05 20:04:11 +00:00
if ( flags & PFS_EZQUAKEMARKUP )
{
ezquakemess = true ;
utf8 = 0 ;
}
2013-03-12 22:44:00 +00:00
if ( flags & PFS_FORCEUTF8 )
utf8 = 2 ;
2009-07-05 18:45:53 +00:00
outsize / = sizeof ( conchar_t ) ;
if ( ! outsize )
return out ;
//then outsize is decremented then checked before each write, so the trailing null has space
2009-05-24 10:11:17 +00:00
#if 0
while ( * str )
{
* out + + = CON_WHITEMASK | ( unsigned char ) * str + + ;
}
* out = 0 ;
2009-07-05 18:45:53 +00:00
return out ;
2009-05-24 10:11:17 +00:00
# endif
if ( * str = = 1 | | * str = = 2 )
{
2013-03-12 22:44:00 +00:00
defaultflags ^ = CON_2NDCHARSETTEXT ;
2009-05-24 10:11:17 +00:00
str + + ;
}
ext = defaultflags ;
2007-06-20 00:02:54 +00:00
while ( * str )
{
2012-02-14 15:50:34 +00:00
if ( * str & 0x80 & & utf8 > 0 )
2009-06-21 17:45:33 +00:00
{ //check for utf-8
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
int decodeerror ;
2013-03-12 22:35:33 +00:00
char * end ;
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
uc = utf8_decode ( & decodeerror , str , & end ) ;
2013-03-31 04:21:08 +00:00
if ( decodeerror & & ! ( utf8 & 2 ) )
2009-06-21 17:45:33 +00:00
{
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
utf8 & = ~ 1 ;
//malformed encoding we just drop through and stop trying to decode.
//if its just a malformed or overlong string, we end up with a chunk of 'red' chars.
2009-06-21 17:45:33 +00:00
}
else
{
2013-03-12 22:44:00 +00:00
if ( uc > CON_CHARMASK )
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
uc = 0xfffd ;
2009-06-21 17:45:33 +00:00
if ( ! - - outsize )
break ;
* out + + = uc | ext ;
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
str = end ;
2009-06-21 17:45:33 +00:00
continue ;
}
}
2014-10-05 20:04:11 +00:00
if ( ezquakemess & & * str = = ' ^ ' )
{
str + + ;
uc = ( unsigned char ) ( * str + + ) ;
* out + + = ( uc | ext ) ^ CON_2NDCHARSETTEXT ;
continue ;
}
else if ( * str = = ' ^ ' & & ! ( flags & PFS_NOMARKUP ) )
2007-06-20 00:02:54 +00:00
{
2009-07-05 18:45:53 +00:00
if ( str [ 1 ] > = ' 0 ' & & str [ 1 ] < = ' 9 ' )
2007-06-20 00:02:54 +00:00
{
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
if ( ext & CON_RICHFORECOLOUR )
ext = ( COLOR_WHITE < < CON_FGSHIFT ) | ( ext & ~ ( CON_RICHFOREMASK | CON_RICHFORECOLOUR ) ) ;
2009-07-05 18:45:53 +00:00
ext = q3codemasks [ str [ 1 ] - ' 0 ' ] | ( ext & ~ CON_Q3MASK ) ; //change colour only.
2007-06-20 00:02:54 +00:00
}
2009-07-05 18:45:53 +00:00
else if ( str [ 1 ] = = ' & ' ) // extended code
2007-06-20 00:02:54 +00:00
{
2009-07-05 18:45:53 +00:00
if ( isextendedcode ( str [ 2 ] ) & & isextendedcode ( str [ 3 ] ) )
2007-06-20 00:02:54 +00:00
{
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
if ( ext & CON_RICHFORECOLOUR )
ext = ( COLOR_WHITE < < CON_FGSHIFT ) | ( ext & ~ ( CON_RICHFOREMASK | CON_RICHFORECOLOUR ) ) ;
2009-07-05 18:45:53 +00:00
// foreground char
if ( str [ 2 ] = = ' - ' ) // default for FG
2007-06-20 00:02:54 +00:00
ext = ( COLOR_WHITE < < CON_FGSHIFT ) | ( ext & ~ CON_FGMASK ) ;
2009-07-05 18:45:53 +00:00
else if ( str [ 2 ] > = ' A ' )
ext = ( ( str [ 2 ] - ( ' A ' - 10 ) ) < < CON_FGSHIFT ) | ( ext & ~ CON_FGMASK ) ;
2007-06-20 00:02:54 +00:00
else
2009-07-05 18:45:53 +00:00
ext = ( ( str [ 2 ] - ' 0 ' ) < < CON_FGSHIFT ) | ( ext & ~ CON_FGMASK ) ;
// background char
if ( str [ 3 ] = = ' - ' ) // default (clear) for BG
2007-06-20 00:02:54 +00:00
ext & = ~ CON_BGMASK & ~ CON_NONCLEARBG ;
2009-07-05 18:45:53 +00:00
else if ( str [ 3 ] > = ' A ' )
ext = ( ( str [ 3 ] - ( ' A ' - 10 ) ) < < CON_BGSHIFT ) | ( ext & ~ CON_BGMASK ) | CON_NONCLEARBG ;
2007-06-20 00:02:54 +00:00
else
2009-07-05 18:45:53 +00:00
ext = ( ( str [ 3 ] - ' 0 ' ) < < CON_BGSHIFT ) | ( ext & ~ CON_BGMASK ) | CON_NONCLEARBG ;
2010-11-10 05:35:14 +00:00
2009-07-05 18:45:53 +00:00
if ( ! keepmarkup )
{
str + = 4 ;
continue ;
}
2007-06-20 00:02:54 +00:00
}
// else invalid code
goto messedup ;
}
2012-10-13 00:56:31 +00:00
else if ( str [ 1 ] = = ' [ ' & & ! linkstart )
{
2013-10-08 14:28:11 +00:00
if ( keepmarkup )
{
if ( ! - - outsize )
break ;
* out + + = ' ^ ' | CON_HIDDEN ;
}
if ( ! - - outsize )
break ;
2012-10-13 00:56:31 +00:00
//preserved flags and reset to white. links must contain their own colours.
linkinitflags = ext ;
ext = COLOR_RED < < CON_FGSHIFT ;
linkstart = out ;
* out + + = ' [ ' ;
//never keep the markup
linkkeep = keepmarkup ;
keepmarkup = false ;
str + = 2 ;
continue ;
}
else if ( str [ 1 ] = = ' ] ' & & linkstart )
{
2013-10-08 14:28:11 +00:00
if ( keepmarkup )
{
if ( ! - - outsize )
break ;
* out + + = ' ^ ' | CON_HIDDEN ;
}
if ( ! - - outsize )
break ;
2012-10-13 00:56:31 +00:00
2014-05-20 02:36:19 +00:00
* out + + = ' ] ' | CON_HIDDEN | CON_LINKSPECIAL ;
2012-10-13 00:56:31 +00:00
//its a valid link, so we can hide it all now
2014-05-20 02:36:19 +00:00
* linkstart + + | = CON_HIDDEN | CON_LINKSPECIAL ; //leading [ is hidden
2012-10-13 00:56:31 +00:00
while ( linkstart < out - 1 & & ( * linkstart & CON_CHARMASK ) ! = ' \\ ' ) //link text is NOT hidden
linkstart + + ;
while ( linkstart < out ) //but the infostring behind it is, as well as the terminator
* linkstart + + | = CON_HIDDEN ;
//reset colours to how they used to be
ext = linkinitflags ;
linkstart = NULL ;
keepmarkup = linkkeep ;
//never keep the markup
str + = 2 ;
continue ;
}
2009-07-05 18:45:53 +00:00
else if ( str [ 1 ] = = ' a ' )
2007-06-20 00:02:54 +00:00
{
ext ^ = CON_2NDCHARSETTEXT ;
}
2009-07-05 18:45:53 +00:00
else if ( str [ 1 ] = = ' b ' )
2007-06-20 00:02:54 +00:00
{
ext ^ = CON_BLINKTEXT ;
}
2009-07-05 18:45:53 +00:00
else if ( str [ 1 ] = = ' d ' )
2009-05-24 10:11:17 +00:00
{
2012-10-13 00:56:31 +00:00
if ( linkstart )
ext = COLOR_RED < < CON_FGSHIFT ;
else
ext = defaultflags ;
2009-05-24 10:11:17 +00:00
}
2009-07-05 18:45:53 +00:00
else if ( str [ 1 ] = = ' m ' )
2013-03-12 22:44:00 +00:00
ext ^ = CON_2NDCHARSETTEXT ;
2009-07-05 18:45:53 +00:00
else if ( str [ 1 ] = = ' h ' )
2007-06-20 00:02:54 +00:00
ext ^ = CON_HALFALPHA ;
2009-07-05 18:45:53 +00:00
else if ( str [ 1 ] = = ' s ' ) //store on stack (it's great for names)
2007-06-20 00:02:54 +00:00
{
if ( extstackdepth < sizeof ( extstack ) / sizeof ( extstack [ 0 ] ) )
{
extstack [ extstackdepth ] = ext ;
extstackdepth + + ;
}
}
2009-07-05 18:45:53 +00:00
else if ( str [ 1 ] = = ' r ' ) //restore from stack (it's great for names)
2007-06-20 00:02:54 +00:00
{
if ( extstackdepth )
{
extstackdepth - - ;
ext = extstack [ extstackdepth ] ;
}
}
2010-07-11 02:22:39 +00:00
else if ( str [ 1 ] = = ' U ' ) //unicode (16bit) char ^Uxxxx
2007-06-20 00:02:54 +00:00
{
2009-07-05 18:45:53 +00:00
if ( ! keepmarkup )
{
uc = 0 ;
uc | = dehex ( str [ 2 ] ) < < 12 ;
uc | = dehex ( str [ 3 ] ) < < 8 ;
uc | = dehex ( str [ 4 ] ) < < 4 ;
uc | = dehex ( str [ 5 ] ) < < 0 ;
if ( ! - - outsize )
break ;
2013-03-12 22:44:00 +00:00
* out + + = uc | ext ;
2009-07-05 18:45:53 +00:00
str + = 6 ;
continue ;
}
}
2013-03-12 22:44:00 +00:00
else if ( str [ 1 ] = = ' { ' ) / / unicode ( Xbit ) char ^ { xxxx }
{
if ( ! keepmarkup )
{
int len ;
uc = 0 ;
2013-05-03 04:28:08 +00:00
for ( len = 2 ; ishexcode ( str [ len ] ) ; len + + )
2013-03-12 22:44:00 +00:00
{
uc < < = 4 ;
uc | = dehex ( str [ len ] ) ;
}
//and eat the close too. oh god I hope its there.
if ( str [ len ] = = ' } ' )
len + + ;
if ( uc > CON_CHARMASK )
uc = 0xfffd ;
if ( ! - - outsize )
break ;
* out + + = uc | ext ;
str + = len ;
continue ;
}
}
2013-12-29 22:48:28 +00:00
else if ( str [ 1 ] = = ' x ' ) //RGB colours
{
if ( ishexcode ( str [ 2 ] ) & & ishexcode ( str [ 3 ] ) & & ishexcode ( str [ 4 ] ) )
{
int r , g , b ;
r = dehex ( str [ 2 ] ) ;
g = dehex ( str [ 3 ] ) ;
b = dehex ( str [ 4 ] ) ;
ext = ( ext & ~ CON_RICHFOREMASK ) | CON_RICHFORECOLOUR ;
ext | = r < < CON_RICHRSHIFT ;
ext | = g < < CON_RICHGSHIFT ;
ext | = b < < CON_RICHBSHIFT ;
if ( ! keepmarkup )
{
str + = 5 ;
continue ;
}
}
}
2009-07-05 18:45:53 +00:00
else if ( str [ 1 ] = = ' ^ ' )
{
if ( keepmarkup )
{
if ( ! - - outsize )
break ;
2013-03-12 22:44:00 +00:00
* out + + = ( unsigned char ) ( * str ) | ext ;
2009-07-05 18:45:53 +00:00
}
2007-06-20 00:02:54 +00:00
str + + ;
2009-07-05 18:45:53 +00:00
if ( * str )
goto messedup ;
continue ;
2007-06-20 00:02:54 +00:00
}
else
{
2009-07-05 18:45:53 +00:00
goto messedup ;
}
if ( ! keepmarkup )
{
str + = 2 ;
continue ;
2007-06-20 00:02:54 +00:00
}
}
2013-03-31 04:21:08 +00:00
else if ( * str = = ' & ' & & str [ 1 ] = = ' c ' & & ! ( flags & PFS_NOMARKUP ) )
2009-05-24 10:11:17 +00:00
{
// ezQuake color codes
if ( ishexcode ( str [ 2 ] ) & & ishexcode ( str [ 3 ] ) & & ishexcode ( str [ 4 ] ) )
{
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
int r , g , b ;
2013-05-03 04:28:08 +00:00
r = dehex ( str [ 2 ] ) ;
g = dehex ( str [ 3 ] ) ;
b = dehex ( str [ 4 ] ) ;
2009-05-24 10:11:17 +00:00
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
ext = ( ext & ~ CON_RICHFOREMASK ) | CON_RICHFORECOLOUR ;
ext | = r < < CON_RICHRSHIFT ;
ext | = g < < CON_RICHGSHIFT ;
ext | = b < < CON_RICHBSHIFT ;
2009-05-24 10:11:17 +00:00
2009-07-05 18:45:53 +00:00
if ( ! keepmarkup )
{
str + = 5 ;
continue ;
}
2009-05-24 10:11:17 +00:00
}
}
2013-03-31 04:21:08 +00:00
else if ( * str = = ' & ' & & str [ 1 ] = = ' r ' & & ! ( flags & PFS_NOMARKUP ) )
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
{
2013-06-23 02:17:02 +00:00
//ezquake revert
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
ext = ( COLOR_WHITE < < CON_FGSHIFT ) | ( ext & ~ ( CON_RICHFOREMASK | CON_RICHFORECOLOUR ) ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
if ( ! keepmarkup )
{
str + = 2 ;
continue ;
}
}
2013-06-23 02:17:02 +00:00
else if ( str [ 0 ] = = ' = ' & & str [ 1 ] = = ' ` ' & & str [ 2 ] = = ' k ' & & str [ 3 ] = = ' 8 ' & & str [ 4 ] = = ' : ' & & ! keepmarkup )
{
2013-11-21 23:02:28 +00:00
//ezquake compat: koi8 compat for crazy russian people.
//we parse for compat but don't generate (they'll see utf-8 from us).
2013-06-23 02:17:02 +00:00
//this code can just recurse. saves affecting the rest of the code with weird encodings.
int l ;
char temp [ 1024 ] ;
str + = 5 ;
while ( * str )
{
l = 0 ;
while ( * str & & l < sizeof ( temp ) - 32 & & ! ( str [ 0 ] = = ' ` ' & & str [ 1 ] = = ' = ' ) )
l + = utf8_encode ( temp + l , koi2wc ( * str + + ) , sizeof ( temp ) - 1 ) ;
//recurse
temp [ l ] = 0 ;
l = COM_ParseFunString ( ext , temp , out , outsize , PFS_FORCEUTF8 ) - out ;
outsize - = l ;
out + = l ;
if ( str [ 0 ] = = ' ` ' & & str [ 1 ] = = ' = ' )
{
str + = 2 ;
break ;
}
}
continue ;
}
2014-03-30 08:55:06 +00:00
else if ( str [ 0 ] = = ' = ' & & str [ 1 ] = = ' ` ' & & str [ 2 ] = = ' u ' & & str [ 3 ] = = ' 8 ' & & str [ 4 ] = = ' : ' & & ! keepmarkup )
{
int l ;
char temp [ 1024 ] ;
str + = 5 ;
while ( * str )
{
l = 0 ;
while ( * str & & l < sizeof ( temp ) - 32 & & ! ( str [ 0 ] = = ' ` ' & & str [ 1 ] = = ' = ' ) )
temp [ l + + ] = * str + + ;
//recurse
temp [ l ] = 0 ;
l = COM_ParseFunString ( ext , temp , out , outsize , PFS_FORCEUTF8 ) - out ;
outsize - = l ;
out + = l ;
if ( str [ 0 ] = = ' ` ' & & str [ 1 ] = = ' = ' )
{
str + = 2 ;
break ;
}
}
continue ;
}
2013-07-13 12:14:32 +00:00
/*
else if ( ( str [ 0 ] = = ' h ' & & str [ 1 ] = = ' t ' & & str [ 2 ] = = ' t ' & & str [ 3 ] = = ' p ' & & str [ 4 ] = = ' : ' & & ! linkstart & & ! ( flags & ( PFS_NOMARKUP | PFS_KEEPMARKUP ) ) ) | |
( str [ 0 ] = = ' h ' & & str [ 1 ] = = ' t ' & & str [ 2 ] = = ' t ' & & str [ 3 ] = = ' p ' & & str [ 4 ] = = ' s ' & & str [ 5 ] = = ' : ' & & ! linkstart & & ! ( flags & ( PFS_NOMARKUP | PFS_KEEPMARKUP ) ) ) )
{
//this code can just recurse. saves affecting the rest of the code with weird encodings.
int l ;
char temp [ 1024 ] ;
conchar_t * ls , * le ;
l = 0 ;
while ( * str & & l < sizeof ( temp ) - 32 & & (
( * str > = ' a ' & & * str < = ' z ' ) | |
( * str > = ' A ' & & * str < = ' Z ' ) | |
( * str > = ' 0 ' & & * str < = ' 9 ' ) | |
* str = = ' . ' | | * str = = ' / ' | | * str = = ' & ' | | * str = = ' = ' | | * str = = ' _ ' | | * str = = ' % ' | | * str = = ' ? ' | | * str = = ' : ' ) )
l + = utf8_encode ( temp + l , * str + + , sizeof ( temp ) - 1 ) ;
//recurse
temp [ l ] = 0 ;
if ( ! - - outsize )
break ;
* out + + = CON_LINKSTART ;
ls = out ;
l = COM_ParseFunString ( COLOR_BLUE < < CON_FGSHIFT , temp , out , outsize , PFS_FORCEUTF8 | PFS_NOMARKUP ) - out ;
outsize - = l ;
out + = l ;
le = out ;
* out + + = ' \\ ' | CON_HIDDEN ;
* out + + = ' u ' | CON_HIDDEN ;
* out + + = ' r ' | CON_HIDDEN ;
* out + + = ' l ' | CON_HIDDEN ;
* out + + = ' \\ ' | CON_HIDDEN ;
while ( ls < le )
* out + + = ( * ls + + & CON_CHARMASK ) | CON_HIDDEN ;
* out + + = CON_LINKEND ;
if ( ! - - outsize )
break ;
* out + + = CON_LINKEND ;
continue ;
}
*/
2007-06-20 00:02:54 +00:00
messedup :
if ( ! - - outsize )
break ;
2012-11-27 03:23:19 +00:00
uc = ( unsigned char ) ( * str + + ) ;
2009-07-05 18:45:53 +00:00
if ( utf8 )
2013-03-12 22:44:00 +00:00
{
//utf8/iso8859-1 has it easy.
2012-11-27 03:23:19 +00:00
* out + + = uc | ext ;
2013-03-12 22:44:00 +00:00
}
2009-07-05 18:45:53 +00:00
else
{
2012-11-27 03:23:19 +00:00
if ( uc = = ' \n ' | | uc = = ' \r ' | | uc = = ' \t ' | | uc = = ' ' )
* out + + = uc | ext ;
2013-03-12 22:44:00 +00:00
else if ( uc > = 32 & & uc < 127 )
* out + + = uc | ext ;
else if ( uc > = 0x80 + 32 & & uc < = 0xff ) //anything using high chars is ascii, with the second charset
* out + + = ( ( uc & 127 ) | ext ) | CON_2NDCHARSETTEXT ;
else //(other) control chars are regular printables in quake, and are not ascii. These ALWAYS use the bitmap/fallback font.
2012-11-27 03:23:19 +00:00
* out + + = uc | ext | 0xe000 ;
2009-07-05 18:45:53 +00:00
}
2007-06-20 00:02:54 +00:00
}
* out = 0 ;
2014-06-30 21:57:35 +00:00
COM_BiDi_Parse ( oldout , out - oldout ) ;
2009-07-05 18:45:53 +00:00
return out ;
2007-06-20 00:02:54 +00:00
}
2013-10-08 14:28:11 +00:00
//remaps conchar_t character values to something valid in unicode, such that it is likely to be printable with standard char sets.
//unicode-to-ascii is not provided. you're expected to utf-8 the result or something.
//does not handle colour codes or hidden chars. add your own escape sequences if you need that.
//does not guarentee removal of control codes if eg the code was specified as an explicit unicode char.
unsigned int COM_DeQuake ( conchar_t chr )
{
chr & = CON_CHARMASK ;
/*only this range are quake chars*/
if ( chr > = 0xe000 & & chr < 0xe100 )
{
chr & = 0xff ;
if ( chr > = 146 & & chr < 156 )
chr = chr - 146 + ' 0 ' ;
if ( chr > = 0x12 & & chr < = 0x1b )
chr = chr - 0x12 + ' 0 ' ;
if ( chr = = 143 )
chr = ' . ' ;
if ( chr = = 128 | | chr = = 129 | | chr = = 130 | | chr = = 157 | | chr = = 158 | | chr = = 159 )
chr = ' - ' ;
if ( chr > = 128 )
chr - = 128 ;
if ( chr = = 16 )
chr = ' [ ' ;
if ( chr = = 17 )
chr = ' ] ' ;
if ( chr = = 0x1c )
chr = 249 ;
}
/*this range contains pictograms*/
if ( chr > = 0xe100 & & chr < 0xe200 )
{
chr = ' ? ' ;
}
return chr ;
}
2004-08-21 01:25:48 +00:00
//============================================================================
# define TOKENSIZE sizeof(com_token)
char com_token [ TOKENSIZE ] ;
int com_argc ;
2009-04-01 22:03:56 +00:00
const char * * com_argv ;
2004-08-21 01:25:48 +00:00
com_tokentype_t com_tokentype ;
/*
= = = = = = = = = = = = = =
COM_Parse
Parse a token out of a string
= = = = = = = = = = = = = =
*/
2009-04-01 22:03:56 +00:00
# ifndef COM_Parse
char * COM_Parse ( const char * data )
2004-08-21 01:25:48 +00:00
{
int c ;
int len ;
2006-01-27 02:45:16 +00:00
2014-10-05 20:04:11 +00:00
if ( out = = com_token )
COM_AssertMainThread ( " COM_ParseOut: com_token " ) ;
2004-08-21 01:25:48 +00:00
len = 0 ;
com_token [ 0 ] = 0 ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
if ( ! data )
return NULL ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
// skip whitespace
skipwhite :
while ( ( c = * data ) < = ' ' )
{
if ( c = = 0 )
return NULL ; // end of file;
data + + ;
}
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
// skip // comments
if ( c = = ' / ' )
{
if ( data [ 1 ] = = ' / ' )
{
while ( * data & & * data ! = ' \n ' )
data + + ;
goto skipwhite ;
}
}
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
// handle quoted strings specially
if ( c = = ' \" ' )
{
data + + ;
while ( 1 )
{
if ( len > = TOKENSIZE - 1 )
2009-04-01 22:03:56 +00:00
return ( char * ) data ;
2004-08-21 01:25:48 +00:00
c = * data + + ;
if ( c = = ' \" ' | | ! c )
{
com_token [ len ] = 0 ;
2009-04-01 22:03:56 +00:00
return ( char * ) data ;
2004-08-21 01:25:48 +00:00
}
com_token [ len ] = c ;
len + + ;
}
}
// parse a regular word
do
{
if ( len > = TOKENSIZE - 1 )
2009-04-01 22:03:56 +00:00
return ( char * ) data ;
2004-08-21 01:25:48 +00:00
com_token [ len ] = c ;
data + + ;
len + + ;
c = * data ;
} while ( c > 32 ) ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
com_token [ len ] = 0 ;
2009-04-01 22:03:56 +00:00
return ( char * ) data ;
2004-08-21 01:25:48 +00:00
}
2009-04-01 22:03:56 +00:00
# endif
2004-08-21 01:25:48 +00:00
2013-07-26 17:19:06 +00:00
//semi-colon delimited tokens
2014-10-05 20:04:11 +00:00
char * COM_ParseStringSet ( const char * data , char * out , size_t outsize )
2007-09-13 22:27:56 +00:00
{
int c ;
int len ;
2014-10-05 20:04:11 +00:00
if ( out = = com_token )
COM_AssertMainThread ( " COM_ParseOut: com_token " ) ;
2007-09-13 22:27:56 +00:00
len = 0 ;
2014-10-05 20:04:11 +00:00
out [ 0 ] = 0 ;
2007-09-13 22:27:56 +00:00
if ( ! data )
return NULL ;
// skip whitespace and semicolons
while ( ( c = * data ) < = ' ' | | c = = ' ; ' )
{
if ( c = = 0 )
return NULL ; // end of file;
data + + ;
}
// parse a regular word
do
{
2014-10-05 20:04:11 +00:00
if ( len > = outsize - 1 )
2009-04-01 22:03:56 +00:00
{
2014-10-05 20:04:11 +00:00
out [ len ] = 0 ;
2009-04-01 22:03:56 +00:00
return ( char * ) data ;
}
2007-09-13 22:27:56 +00:00
2014-10-05 20:04:11 +00:00
out [ len ] = c ;
2007-09-13 22:27:56 +00:00
data + + ;
len + + ;
2014-06-30 21:57:35 +00:00
c = * ( unsigned char * ) data ;
2007-09-13 22:27:56 +00:00
} while ( c > 32 & & c ! = ' ; ' ) ;
2014-10-05 20:04:11 +00:00
out [ len ] = 0 ;
2009-04-01 22:03:56 +00:00
return ( char * ) data ;
2007-09-13 22:27:56 +00:00
}
2009-04-01 22:03:56 +00:00
char * COM_ParseOut ( const char * data , char * out , int outlen )
2004-08-21 01:25:48 +00:00
{
int c ;
int len ;
2006-01-27 02:45:16 +00:00
2014-10-05 20:04:11 +00:00
if ( out = = com_token )
COM_AssertMainThread ( " COM_ParseOut: com_token " ) ;
2004-08-21 01:25:48 +00:00
len = 0 ;
out [ 0 ] = 0 ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
if ( ! data )
return NULL ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
// skip whitespace
skipwhite :
while ( ( c = * data ) < = ' ' )
{
if ( c = = 0 )
return NULL ; // end of file;
data + + ;
}
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
// skip // comments
if ( c = = ' / ' )
{
if ( data [ 1 ] = = ' / ' )
{
while ( * data & & * data ! = ' \n ' )
data + + ;
goto skipwhite ;
}
}
2006-01-27 02:45:16 +00:00
2011-02-25 04:22:14 +00:00
//skip / * comments
if ( c = = ' / ' & & data [ 1 ] = = ' * ' )
{
data + = 2 ;
while ( * data )
{
if ( * data = = ' * ' & & data [ 1 ] = = ' / ' )
{
data + = 2 ;
goto skipwhite ;
}
data + + ;
}
goto skipwhite ;
}
2004-08-21 01:25:48 +00:00
// handle quoted strings specially
if ( c = = ' \" ' )
{
data + + ;
while ( 1 )
{
if ( len > = outlen - 1 )
2009-04-01 22:03:56 +00:00
{
out [ len ] = 0 ;
return ( char * ) data ;
}
2004-08-21 01:25:48 +00:00
c = * data + + ;
if ( c = = ' \" ' | | ! c )
{
out [ len ] = 0 ;
2009-04-01 22:03:56 +00:00
return ( char * ) data ;
2004-08-21 01:25:48 +00:00
}
out [ len ] = c ;
len + + ;
}
}
// parse a regular word
do
{
if ( len > = outlen - 1 )
2009-04-01 22:03:56 +00:00
{
out [ len ] = 0 ;
return ( char * ) data ;
}
2004-08-21 01:25:48 +00:00
out [ len ] = c ;
data + + ;
len + + ;
c = * data ;
} while ( c > 32 ) ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
out [ len ] = 0 ;
2009-04-01 22:03:56 +00:00
return ( char * ) data ;
2004-08-21 01:25:48 +00:00
}
//same as COM_Parse, but parses two quotes next to each other as a single quote as part of the string
2011-02-25 04:22:14 +00:00
char * COM_StringParse ( const char * data , char * token , unsigned int tokenlen , qboolean expandmacros , qboolean qctokenize )
2004-08-21 01:25:48 +00:00
{
int c ;
int len ;
2005-03-28 00:11:59 +00:00
char * s ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
len = 0 ;
2011-02-25 04:22:14 +00:00
token [ 0 ] = 0 ;
2006-01-27 02:45:16 +00:00
2014-10-05 20:04:11 +00:00
if ( token = = com_token )
COM_AssertMainThread ( " COM_ParseOut: com_token " ) ;
2004-08-21 01:25:48 +00:00
if ( ! data )
return NULL ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
// skip whitespace
skipwhite :
2005-08-03 23:14:59 +00:00
while ( ( c = * data ) , ( unsigned ) c < = ' ' & & c ! = ' \n ' )
2004-08-21 01:25:48 +00:00
{
if ( c = = 0 )
return NULL ; // end of file;
data + + ;
}
2010-07-18 08:42:59 +00:00
if ( c = = ' \n ' )
{
2011-02-25 04:22:14 +00:00
token [ len + + ] = c ;
token [ len ] = 0 ;
2010-07-18 08:42:59 +00:00
return ( char * ) data + 1 ;
}
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
// skip // comments
if ( c = = ' / ' )
{
if ( data [ 1 ] = = ' / ' )
{
while ( * data & & * data ! = ' \n ' )
data + + ;
goto skipwhite ;
}
}
2005-02-28 07:16:19 +00:00
//skip / * comments
if ( c = = ' / ' & & data [ 1 ] = = ' * ' & & ! qctokenize )
{
data + = 2 ;
while ( * data )
{
if ( * data = = ' * ' & & data [ 1 ] = = ' / ' )
{
data + = 2 ;
goto skipwhite ;
}
data + + ;
}
goto skipwhite ;
}
2006-01-27 02:45:16 +00:00
2013-07-26 17:19:06 +00:00
if ( c = = ' \\ ' & & data [ 1 ] = = ' \" ' )
{
2013-11-21 23:02:28 +00:00
return COM_ParseCString ( data + 1 , token , tokenlen , NULL ) ;
2013-07-26 17:19:06 +00:00
}
2004-08-21 01:25:48 +00:00
// handle quoted strings specially
if ( c = = ' \" ' )
{
data + + ;
while ( 1 )
{
2011-02-25 04:22:14 +00:00
if ( len > = tokenlen - 1 )
2004-12-05 11:39:39 +00:00
{
2011-02-25 04:22:14 +00:00
token [ len ] = ' \0 ' ;
2009-04-01 22:03:56 +00:00
return ( char * ) data ;
2004-12-05 11:39:39 +00:00
}
2004-08-21 01:25:48 +00:00
c = * data + + ;
if ( c = = ' \" ' )
{
c = * ( data ) ;
if ( c ! = ' \" ' )
{
2011-02-25 04:22:14 +00:00
token [ len ] = 0 ;
2009-04-01 22:03:56 +00:00
return ( char * ) data ;
2004-08-21 01:25:48 +00:00
}
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
data + + ;
/* while (c=='\"')
2004-08-21 01:25:48 +00:00
{
2011-02-25 04:22:14 +00:00
token [ len ] = c ;
2004-08-21 01:25:48 +00:00
len + + ;
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
c = * + + data ;
2004-08-21 01:25:48 +00:00
}
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
*/
2004-08-21 01:25:48 +00:00
}
if ( ! c )
{
2011-02-25 04:22:14 +00:00
token [ len ] = 0 ;
2009-06-21 17:45:33 +00:00
return ( char * ) data - 1 ;
2004-08-21 01:25:48 +00:00
}
2011-02-25 04:22:14 +00:00
token [ len ] = c ;
2004-08-21 01:25:48 +00:00
len + + ;
}
}
2004-12-08 04:14:52 +00:00
// handle quoted strings specially
if ( c = = ' \' ' & & qctokenize )
{
data + + ;
while ( 1 )
{
2011-02-25 04:22:14 +00:00
if ( len > = tokenlen - 1 )
2004-12-08 04:14:52 +00:00
{
2011-02-25 04:22:14 +00:00
token [ len ] = ' \0 ' ;
2009-04-01 22:03:56 +00:00
return ( char * ) data ;
2004-12-08 04:14:52 +00:00
}
c = * data + + ;
if ( c = = ' \' ' )
{
c = * ( data ) ;
if ( c ! = ' \' ' )
{
2011-02-25 04:22:14 +00:00
token [ len ] = 0 ;
2009-04-01 22:03:56 +00:00
return ( char * ) data ;
2004-12-08 04:14:52 +00:00
}
while ( c = = ' \' ' )
{
2011-02-25 04:22:14 +00:00
token [ len ] = c ;
2004-12-08 04:14:52 +00:00
len + + ;
data + + ;
c = * ( data + 1 ) ;
}
}
if ( ! c )
{
2011-02-25 04:22:14 +00:00
token [ len ] = 0 ;
2009-04-01 22:03:56 +00:00
return ( char * ) data ;
2004-12-08 04:14:52 +00:00
}
2011-02-25 04:22:14 +00:00
token [ len ] = c ;
2004-12-08 04:14:52 +00:00
len + + ;
}
}
if ( qctokenize & & ( c = = ' \n ' | | c = = ' { ' | | c = = ' } ' | | c = = ' ) ' | | c = = ' ( ' | | c = = ' ] ' | | c = = ' [ ' | | c = = ' \' ' | | c = = ' : ' | | c = = ' , ' | | c = = ' ; ' ) )
{
// single character
2011-02-25 04:22:14 +00:00
token [ len + + ] = c ;
token [ len ] = 0 ;
2009-04-01 22:03:56 +00:00
return ( char * ) data + 1 ;
2004-12-08 04:14:52 +00:00
}
2004-08-21 01:25:48 +00:00
// parse a regular word
do
{
2011-02-25 04:22:14 +00:00
if ( len > = tokenlen - 1 )
2004-12-05 11:39:39 +00:00
{
2011-02-25 04:22:14 +00:00
token [ len ] = ' \0 ' ;
2009-04-01 22:03:56 +00:00
return ( char * ) data ;
2004-12-05 11:39:39 +00:00
}
2004-08-21 01:25:48 +00:00
2011-02-25 04:22:14 +00:00
token [ len ] = c ;
2004-08-21 01:25:48 +00:00
data + + ;
len + + ;
c = * data ;
2005-08-03 23:14:59 +00:00
} while ( ( unsigned ) c > 32 & & ! ( qctokenize & & ( c = = ' \n ' | | c = = ' { ' | | c = = ' } ' | | c = = ' ) ' | | c = = ' ( ' | | c = = ' ] ' | | c = = ' [ ' | | c = = ' \' ' | | c = = ' : ' | | c = = ' , ' | | c = = ' ; ' ) ) ) ;
2004-08-21 01:25:48 +00:00
2011-02-25 04:22:14 +00:00
token [ len ] = 0 ;
2004-12-08 04:14:52 +00:00
if ( ! expandmacros )
2009-04-01 22:03:56 +00:00
return ( char * ) data ;
2004-12-08 04:14:52 +00:00
2004-08-21 01:25:48 +00:00
//now we check for macros.
2011-02-25 04:22:14 +00:00
for ( s = token , c = 0 ; c < len ; c + + , s + + ) //this isn't a quoted token by the way.
2004-08-21 01:25:48 +00:00
{
if ( * s = = ' $ ' )
{
cvar_t * macro ;
char name [ 64 ] ;
int i ;
for ( i = 1 ; i < sizeof ( name ) ; i + + )
{
2005-03-28 00:11:59 +00:00
if ( ( ( unsigned char * ) s ) [ i ] < = ' ' | | s [ i ] = = ' $ ' )
2004-08-21 01:25:48 +00:00
break ;
}
Q_strncpyz ( name , s + 1 , i ) ;
i - = 1 ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
macro = Cvar_FindVar ( name ) ;
if ( macro ) //got one...
{
2011-02-25 04:22:14 +00:00
if ( len + strlen ( macro - > string ) - ( i + 1 ) > = tokenlen - 1 ) //give up.
2004-12-05 11:39:39 +00:00
{
2011-02-25 04:22:14 +00:00
token [ len ] = ' \0 ' ;
2009-04-01 22:03:56 +00:00
return ( char * ) data ;
2004-12-05 11:39:39 +00:00
}
2004-08-21 01:25:48 +00:00
memmove ( s + strlen ( macro - > string ) , s + i + 1 , len - c - i ) ;
memcpy ( s , macro - > string , strlen ( macro - > string ) ) ;
s + = strlen ( macro - > string ) ;
len + = strlen ( macro - > string ) - ( i + 1 ) ;
}
}
}
2006-01-27 02:45:16 +00:00
2009-04-01 22:03:56 +00:00
return ( char * ) data ;
2004-08-21 01:25:48 +00:00
}
2005-08-26 22:56:51 +00:00
# define DEFAULT_PUNCTUATION "(,{})(\':;=!><&|+"
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
{
int c ;
int len ;
2005-08-26 22:56:51 +00:00
if ( ! punctuation )
punctuation = DEFAULT_PUNCTUATION ;
2006-01-27 02:45:16 +00:00
2014-10-05 20:04:11 +00:00
COM_AssertMainThread ( " COM_ParseOut: com_token " ) ;
2004-08-21 01:25:48 +00:00
len = 0 ;
com_token [ 0 ] = 0 ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
if ( ! data )
2006-03-14 01:15:42 +00:00
{
com_tokentype = TTP_UNKNOWN ;
2004-08-21 01:25:48 +00:00
return NULL ;
2006-03-14 01:15:42 +00:00
}
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
// skip whitespace
skipwhite :
2008-11-09 22:29:28 +00:00
while ( ( c = * ( unsigned char * ) data ) < = ' ' & & c ! = ' \r ' & & c ! = ' \n ' )
2004-08-21 01:25:48 +00:00
{
if ( c = = 0 )
2006-03-14 01:15:42 +00:00
{
com_tokentype = TTP_UNKNOWN ;
2004-08-21 01:25:48 +00:00
return NULL ; // end of file;
2006-03-14 01:15:42 +00:00
}
2004-08-21 01:25:48 +00:00
data + + ;
}
2006-01-27 02:45:16 +00:00
2008-11-09 22:29:28 +00:00
//if windows, ignore the \r.
if ( c = = ' \r ' & & data [ 1 ] = = ' \n ' )
c = * ( unsigned char * ) data + + ;
if ( c = = ' \r ' | | c = = ' \n ' )
{
com_tokentype = TTP_LINEENDING ;
com_token [ 0 ] = ' \n ' ;
com_token [ 1 ] = ' \0 ' ;
data + + ;
return ( char * ) data ;
}
2004-08-21 01:25:48 +00:00
// skip // comments
if ( c = = ' / ' )
{
if ( data [ 1 ] = = ' / ' )
{
while ( * data & & * data ! = ' \n ' )
data + + ;
goto skipwhite ;
}
else if ( data [ 1 ] = = ' * ' )
{
data + = 2 ;
while ( * data & & ( * data ! = ' * ' | | data [ 1 ] ! = ' / ' ) )
data + + ;
2008-11-09 22:29:28 +00:00
if ( * data )
data + + ;
if ( * data )
data + + ;
2004-08-21 01:25:48 +00:00
goto skipwhite ;
}
}
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
// handle quoted strings specially
if ( c = = ' \" ' )
{
com_tokentype = TTP_STRING ;
data + + ;
while ( 1 )
{
2004-12-05 11:39:39 +00:00
if ( len > = TOKENSIZE - 1 )
{
com_token [ len ] = ' \0 ' ;
2006-09-17 00:59:22 +00:00
return ( char * ) data ;
2004-12-05 11:39:39 +00:00
}
2004-08-21 01:25:48 +00:00
c = * data + + ;
if ( c = = ' \" ' | | ! c )
{
com_token [ len ] = 0 ;
2006-09-17 00:59:22 +00:00
return ( char * ) data ;
2004-08-21 01:25:48 +00:00
}
com_token [ len ] = c ;
len + + ;
}
}
com_tokentype = TTP_UNKNOWN ;
// parse single characters
2005-08-26 22:56:51 +00:00
if ( strchr ( punctuation , c ) )
2004-08-21 01:25:48 +00:00
{
com_token [ len ] = c ;
len + + ;
com_token [ len ] = 0 ;
2006-09-17 00:59:22 +00:00
return ( char * ) ( data + 1 ) ;
2004-08-21 01:25:48 +00:00
}
// parse a regular word
do
{
2005-10-01 03:09:17 +00:00
if ( len > = TOKENSIZE - 1 )
2004-12-05 11:39:39 +00:00
break ;
2004-08-21 01:25:48 +00:00
com_token [ len ] = c ;
data + + ;
len + + ;
c = * data ;
2005-08-26 22:56:51 +00:00
if ( strchr ( punctuation , c ) )
2004-08-21 01:25:48 +00:00
break ;
} while ( c > 32 ) ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
com_token [ len ] = 0 ;
2006-09-17 00:59:22 +00:00
return ( char * ) data ;
2004-08-21 01:25:48 +00:00
}
2013-07-26 17:19:06 +00:00
const char * COM_QuotedString ( const char * string , char * buf , int buflen )
{
const char * result = buf ;
if ( strchr ( string , ' \r ' ) | | strchr ( string , ' \n ' ) | | strchr ( string , ' \" ' ) )
{
* buf + + = ' \\ ' ; //prefix so the reader knows its a quoted string.
* buf + + = ' \" ' ; //opening quote
buflen - = 4 ;
while ( * string & & buflen > = 2 )
{
switch ( * string )
{
case ' \n ' :
* buf + + = ' \\ ' ;
* buf + + = ' n ' ;
break ;
case ' \r ' :
* buf + + = ' \\ ' ;
* buf + + = ' r ' ;
break ;
2013-11-21 23:02:28 +00:00
case ' \t ' :
* buf + + = ' \\ ' ;
* buf + + = ' t ' ;
break ;
2013-07-26 17:19:06 +00:00
case ' \' ' :
* buf + + = ' \\ ' ;
* buf + + = ' \' ' ;
break ;
case ' \" ' :
* buf + + = ' \\ ' ;
* buf + + = ' \" ' ;
break ;
case ' \\ ' :
* buf + + = ' \\ ' ;
* buf + + = ' \\ ' ;
break ;
case ' $ ' :
* buf + + = ' \\ ' ;
* buf + + = ' $ ' ;
break ;
default :
* buf + + = * string ;
break ;
}
string + + ;
}
* buf + + = ' \" ' ; //closing quote
* buf + + = 0 ;
return result ;
}
else
{
* buf + + = ' \" ' ; //opening quote
buflen - = 3 ;
while ( * string & & buflen > = 0 )
{
* buf + + = * string + + ;
}
* buf + + = ' \" ' ; //closing quote
* buf + + = 0 ;
return result ;
}
}
2013-11-21 23:02:28 +00:00
char * COM_ParseCString ( const char * data , char * token , size_t sizeoftoken , size_t * lengthwritten )
2004-08-21 01:25:48 +00:00
{
int c ;
2013-11-21 23:02:28 +00:00
size_t len ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
len = 0 ;
2013-07-26 17:19:06 +00:00
token [ 0 ] = 0 ;
2006-01-27 02:45:16 +00:00
2014-10-05 20:04:11 +00:00
if ( token = = com_token )
COM_AssertMainThread ( " COM_ParseCString: com_token " ) ;
2013-11-21 23:02:28 +00:00
if ( lengthwritten )
* lengthwritten = 0 ;
2004-08-21 01:25:48 +00:00
if ( ! data )
return NULL ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
// skip whitespace
skipwhite :
while ( ( c = * data ) < = ' ' )
{
if ( c = = 0 )
return NULL ; // end of file;
data + + ;
}
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
// skip // comments
if ( c = = ' / ' )
{
if ( data [ 1 ] = = ' / ' )
{
while ( * data & & * data ! = ' \n ' )
data + + ;
goto skipwhite ;
}
}
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
// handle quoted strings specially
if ( c = = ' \" ' )
{
data + + ;
while ( 1 )
{
2013-11-21 23:02:28 +00:00
if ( len > = sizeoftoken - 2 )
2004-12-05 11:39:39 +00:00
{
2013-07-26 17:19:06 +00:00
token [ len ] = ' \0 ' ;
2013-11-21 23:02:28 +00:00
if ( lengthwritten )
* lengthwritten = len ;
2009-04-01 22:03:56 +00:00
return ( char * ) data ;
2004-12-05 11:39:39 +00:00
}
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
c = * data + + ;
if ( ! c )
{
2013-07-26 17:19:06 +00:00
token [ len ] = 0 ;
2013-11-21 23:02:28 +00:00
if ( lengthwritten )
* lengthwritten = len ;
2013-08-21 07:14:39 +00:00
return ( char * ) data - 1 ;
2004-08-21 01:25:48 +00:00
}
if ( c = = ' \\ ' )
{
c = * data + + ;
switch ( c )
{
2013-07-26 17:19:06 +00:00
case ' \r ' :
if ( * data = = ' \n ' )
data + + ;
case ' \n ' :
continue ;
2004-08-21 01:25:48 +00:00
case ' n ' :
c = ' \n ' ;
break ;
2013-11-21 23:02:28 +00:00
case ' t ' :
c = ' \t ' ;
break ;
2013-07-26 17:19:06 +00:00
case ' r ' :
c = ' \r ' ;
break ;
case ' $ ' :
2004-08-21 01:25:48 +00:00
case ' \\ ' :
2013-07-26 17:19:06 +00:00
case ' \' ' :
2004-08-21 01:25:48 +00:00
break ;
case ' " ' :
c = ' " ' ;
2013-07-26 17:19:06 +00:00
token [ len ] = c ;
2004-08-21 01:25:48 +00:00
len + + ;
continue ;
default :
2013-07-26 17:19:06 +00:00
c = ' ? ' ;
break ;
2004-08-21 01:25:48 +00:00
}
}
if ( c = = ' \" ' | | ! c )
{
2013-07-26 17:19:06 +00:00
token [ len ] = 0 ;
2013-11-21 23:02:28 +00:00
if ( lengthwritten )
* lengthwritten = len ;
2009-04-01 22:03:56 +00:00
return ( char * ) data ;
2004-08-21 01:25:48 +00:00
}
2013-07-26 17:19:06 +00:00
token [ len ] = c ;
2004-08-21 01:25:48 +00:00
len + + ;
}
}
// parse a regular word
do
{
2013-11-21 23:02:28 +00:00
if ( len > = sizeoftoken - 1 )
2004-12-05 11:39:39 +00:00
break ;
2013-07-26 17:19:06 +00:00
token [ len ] = c ;
2004-08-21 01:25:48 +00:00
data + + ;
len + + ;
c = * data ;
} while ( c > 32 ) ;
2006-01-27 02:45:16 +00:00
2013-07-26 17:19:06 +00:00
token [ len ] = 0 ;
2013-11-21 23:02:28 +00:00
if ( lengthwritten )
* lengthwritten = len ;
2009-04-01 22:03:56 +00:00
return ( char * ) data ;
2004-08-21 01:25:48 +00:00
}
/*
= = = = = = = = = = = = = = = =
COM_CheckParm
Returns the position ( 1 to argc - 1 ) in the program ' s argument list
where the given parameter apears , or 0 if not present
= = = = = = = = = = = = = = = =
*/
2009-04-01 22:03:56 +00:00
int COM_CheckNextParm ( const char * parm , int last )
2004-08-21 01:25:48 +00:00
{
int i = last + 1 ;
2006-01-27 02:45:16 +00:00
2005-06-25 03:03:32 +00:00
for ( ; i < com_argc ; i + + )
2004-08-21 01:25:48 +00:00
{
if ( ! com_argv [ i ] )
continue ; // NEXTSTEP sometimes clears appkit vars.
if ( ! Q_strcmp ( parm , com_argv [ i ] ) )
return i ;
}
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
return 0 ;
}
2009-04-01 22:03:56 +00:00
int COM_CheckParm ( const char * parm )
2004-08-21 01:25:48 +00:00
{
return COM_CheckNextParm ( parm , 0 ) ;
}
2005-01-07 02:45:03 +00:00
/*
= = = = = = = = = = = = = = =
COM_ParsePlusSets
Looks for + set blah blah on the commandline , and creates cvars so that engine
functions may use the cvar before anything ' s loaded .
This isn ' t really needed , but might make some thing nicer .
= = = = = = = = = = = = = = =
*/
2014-10-05 20:04:11 +00:00
void COM_ParsePlusSets ( qboolean docbuf )
2005-01-07 02:45:03 +00:00
{
int i ;
for ( i = 1 ; i < com_argc - 2 ; i + + )
{
if ( ! com_argv [ i ] )
continue ; // NEXTSTEP sometimes clears appkit vars.
if ( ! com_argv [ i + 1 ] )
continue ;
if ( ! com_argv [ i + 2 ] )
continue ;
if ( * com_argv [ i + 1 ] = = ' - ' | | * com_argv [ i + 1 ] = = ' + ' )
continue ; //erm
if ( * com_argv [ i + 2 ] = = ' - ' | | * com_argv [ i + 2 ] = = ' + ' )
continue ; //erm
2014-10-05 20:04:11 +00:00
if ( docbuf )
{
if ( ! strcmp ( com_argv [ i ] , " +set " ) | | ! strcmp ( com_argv [ i ] , " +seta " ) )
{
Cbuf_AddText ( com_argv [ i ] + 1 , RESTRICT_LOCAL ) ;
Cbuf_AddText ( " " , RESTRICT_LOCAL ) ;
Cbuf_AddText ( com_argv [ i + 1 ] , RESTRICT_LOCAL ) ;
Cbuf_AddText ( " " , RESTRICT_LOCAL ) ;
Cbuf_AddText ( com_argv [ i + 2 ] , RESTRICT_LOCAL ) ;
Cbuf_AddText ( " \n " , RESTRICT_LOCAL ) ;
}
}
else
{
if ( ! strcmp ( com_argv [ i ] , " +set " ) )
Cvar_Get ( com_argv [ i + 1 ] , com_argv [ i + 2 ] , 0 , " Cvars set on commandline " ) ;
else if ( ! strcmp ( com_argv [ i ] , " +seta " ) )
Cvar_Get ( com_argv [ i + 1 ] , com_argv [ i + 2 ] , CVAR_ARCHIVE , " Cvars set on commandline " ) ;
}
2005-01-07 02:45:03 +00:00
i + = 2 ;
}
}
2013-10-29 17:38:22 +00:00
void Cvar_DefaultFree ( char * str ) ;
2004-08-21 01:25:48 +00:00
/*
= = = = = = = = = = = = = = = =
COM_CheckRegistered
Looks for the pop . txt file and verifies it .
Sets the " registered " cvar .
Immediately exits out if an alternate game was attempted to be started without
being registered .
= = = = = = = = = = = = = = = =
*/
void COM_CheckRegistered ( void )
{
2013-09-26 09:24:52 +00:00
char * newdef ;
2005-12-21 03:07:33 +00:00
vfsfile_t * h ;
2004-08-21 01:25:48 +00:00
2006-01-02 22:58:16 +00:00
h = FS_OpenVFS ( " gfx/pop.lmp " , " rb " , FS_GAME ) ;
2004-08-21 01:25:48 +00:00
2013-09-26 09:24:52 +00:00
if ( h )
{
static_registered = true ;
VFS_CLOSE ( h ) ;
}
else
static_registered = false ;
2006-01-27 02:45:16 +00:00
2013-09-26 09:24:52 +00:00
newdef = static_registered ? " 1 " : " 0 " ;
2013-10-29 17:38:22 +00:00
if ( strcmp ( registered . enginevalue , newdef ) )
2013-09-26 09:24:52 +00:00
{
2013-10-29 17:38:22 +00:00
if ( registered . defaultstr ! = registered . enginevalue )
{
Cvar_DefaultFree ( registered . defaultstr ) ;
registered . defaultstr = NULL ;
}
registered . enginevalue = newdef ;
2013-09-26 09:24:52 +00:00
registered . defaultstr = newdef ;
Cvar_ForceSet ( & registered , newdef ) ;
if ( static_registered )
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Playing registered version. \n " ) ;
2013-09-26 09:24:52 +00:00
}
2004-08-21 01:25:48 +00:00
}
/*
= = = = = = = = = = = = = = = =
COM_InitArgv
= = = = = = = = = = = = = = = =
*/
2009-04-01 22:03:56 +00:00
void COM_InitArgv ( int argc , const char * * argv ) //not allowed to tprint
2004-08-21 01:25:48 +00:00
{
qboolean safe ;
int i ;
2011-05-15 13:23:13 +00:00
size_t result ;
2004-08-21 01:25:48 +00:00
2013-08-07 14:20:24 +00:00
# if !defined(NACL) && !defined(FTE_TARGET_WEB)
2004-08-21 01:25:48 +00:00
FILE * f ;
2011-09-05 01:48:23 +00:00
if ( argv & & argv [ 0 ] )
f = fopen ( va ( " %s_p.txt " , argv [ 0 ] ) , " rb " ) ;
else
f = NULL ;
2004-08-21 01:25:48 +00:00
if ( f )
{
char * buffer ;
int len ;
fseek ( f , 0 , SEEK_END ) ;
len = ftell ( f ) ;
fseek ( f , 0 , SEEK_SET ) ;
2005-03-28 00:11:59 +00:00
buffer = ( char * ) malloc ( len + 1 ) ;
2011-05-15 13:23:13 +00:00
result = fread ( buffer , 1 , len , f ) ; // do something with result
2011-05-30 04:32:04 +00:00
if ( result ! = len )
2011-06-01 13:21:54 +00:00
Con_Printf ( " COM_InitArgv() fread: Filename: %s, expected %i, result was %u (%s) \n " , va ( " %s_p.txt " , argv [ 0 ] ) , len , ( unsigned int ) result , strerror ( errno ) ) ;
2011-05-30 04:32:04 +00:00
2004-08-21 01:25:48 +00:00
buffer [ len ] = ' \0 ' ;
while ( * buffer & & ( argc < MAX_NUM_ARGVS ) )
{
while ( * buffer & & ( ( * buffer < = 32 ) | | ( * buffer > 126 ) ) )
buffer + + ;
if ( * buffer )
{
argv [ argc ] = buffer ;
argc + + ;
while ( * buffer & & ( ( * buffer > 32 ) & & ( * buffer < = 126 ) ) )
buffer + + ;
if ( * buffer )
{
* buffer = 0 ;
buffer + + ;
}
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
}
}
fclose ( f ) ;
}
2012-04-24 07:59:11 +00:00
# endif
2004-08-21 01:25:48 +00:00
safe = false ;
for ( com_argc = 0 ; ( com_argc < MAX_NUM_ARGVS ) & & ( com_argc < argc ) ;
com_argc + + )
{
largv [ com_argc ] = argv [ com_argc ] ;
if ( ! Q_strcmp ( " -safe " , argv [ com_argc ] ) )
safe = true ;
}
if ( safe )
2006-01-27 02:45:16 +00:00
{
2004-08-21 01:25:48 +00:00
// force all the safe-mode switches. Note that we reserved extra space in
// case we need to add these, so we don't need an overflow check
for ( i = 0 ; i < NUM_SAFE_ARGVS ; i + + )
{
largv [ com_argc ] = safeargvs [ i ] ;
com_argc + + ;
}
}
largv [ com_argc ] = argvdummy ;
com_argv = largv ;
}
/*
= = = = = = = = = = = = = = = =
COM_AddParm
Adds the given string at the end of the current argument list
= = = = = = = = = = = = = = = =
*/
2009-04-01 22:03:56 +00:00
void COM_AddParm ( const char * parm )
2004-08-21 01:25:48 +00:00
{
largv [ com_argc + + ] = parm ;
}
2009-02-22 13:50:17 +00:00
/*
= = = = = = = = = = = = = = = = = = = = = = =
COM_Version_f
= = = = = = = = = = = = = = = = = = = = = =
*/
void COM_Version_f ( void )
{
2011-06-25 13:06:20 +00:00
Con_Printf ( " %s \n " , version_string ( ) ) ;
2009-02-22 13:50:17 +00:00
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Exe: %s %s \n " , __DATE__ , __TIME__ ) ;
2009-02-22 13:50:17 +00:00
2009-07-25 11:22:28 +00:00
# ifdef SVNREVISION
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
if ( strcmp ( STRINGIFY ( SVNREVISION ) , " - " ) )
Con_Printf ( " SVN Revision: %s \n " , STRINGIFY ( SVNREVISION ) ) ;
2009-07-25 11:22:28 +00:00
# endif
2009-04-19 05:01:55 +00:00
# ifdef _DEBUG
Con_Printf ( " debug build \n " ) ;
# endif
2010-12-12 14:17:22 +00:00
# ifdef MINIMAL
Con_Printf ( " minimal build \n " ) ;
# endif
2009-02-22 13:50:17 +00:00
# ifdef CLIENTONLY
Con_Printf ( " client-only build \n " ) ;
# endif
# ifdef SERVERONLY
Con_Printf ( " dedicated server build \n " ) ;
2014-10-05 20:04:11 +00:00
# else
Con_Printf ( " Renderers: " ) ;
2010-12-12 14:17:22 +00:00
# ifdef GLQUAKE
2014-10-05 20:04:11 +00:00
# ifdef GLESONLY
Con_Printf ( " OpenGLES " ) ;
# else
Con_Printf ( " OpenGL " ) ;
# endif
# ifdef GLSLONLY
Con_Printf ( " (GLSL) " ) ;
# endif
2010-12-12 14:17:22 +00:00
# endif
2012-09-30 05:52:03 +00:00
# ifdef D3D9QUAKE
2014-10-05 20:04:11 +00:00
Con_Printf ( " Direct3D9 " ) ;
2012-09-30 05:52:03 +00:00
# endif
# ifdef D3D11QUAKE
2014-10-05 20:04:11 +00:00
Con_Printf ( " Direct3D11 " ) ;
# endif
# ifdef SWQUAKE
Con_Printf ( " Software " ) ;
# endif
Con_Printf ( " \n " ) ;
2011-01-28 05:39:40 +00:00
# endif
2010-12-12 14:17:22 +00:00
2011-07-13 13:43:20 +00:00
# ifdef QCJIT
Con_Printf ( " QuakeC just-in-time compiler (QCJIT) enabled \n " ) ;
# endif
2014-02-09 09:25:28 +00:00
# ifdef FTE_SDL
2010-11-14 10:16:40 +00:00
Con_Printf ( " SDL version: %d.%d.%d \n " , SDL_MAJOR_VERSION , SDL_MINOR_VERSION , SDL_PATCHLEVEL ) ;
# endif
2010-12-12 14:17:22 +00:00
// Don't print both as a 64bit MinGW built client
2011-01-28 05:39:40 +00:00
# if defined(__MINGW32__)
Con_Printf ( " Compiled with MinGW32/64 version: %i.%i \n " , __MINGW32_MAJOR_VERSION , __MINGW32_MINOR_VERSION ) ;
2009-04-19 05:01:55 +00:00
# endif
# ifdef __CYGWIN__
Con_Printf ( " Compiled with Cygwin \n " ) ;
# endif
2013-10-29 17:38:22 +00:00
# ifdef __clang__
Con_Printf ( " Compiled with clang version: %i.%i.%i (%s) \n " , __clang_major__ , __clang_minor__ , __clang_patchlevel__ , __VERSION__ ) ;
# elif defined(__GNUC__)
2010-07-11 10:53:13 +00:00
Con_Printf ( " Compiled with GCC version: %i.%i.%i (%s) \n " , __GNUC__ , __GNUC_MINOR__ , __GNUC_PATCHLEVEL__ , __VERSION__ ) ;
2009-04-19 05:01:55 +00:00
# ifdef __OPTIMIZE__
# ifdef __OPTIMIZE_SIZE__
Con_Printf ( " Optimized for size \n " ) ;
# else
Con_Printf ( " Optimized for speed \n " ) ;
# endif
# endif
# ifdef __NO_INLINE__
Con_Printf ( " GCC Optimization: Functions currently not inlined into their callers \n " ) ;
# else
Con_Printf ( " GCC Optimization: Functions currently inlined into their callers \n " ) ;
# endif
# endif
2010-11-02 23:17:25 +00:00
# ifdef _WIN64
Con_Printf ( " Compiled for 64bit windows \n " ) ;
# endif
2011-06-02 05:16:44 +00:00
# if defined(_M_AMD64) || defined(__amd64__)
2010-11-02 23:17:25 +00:00
Con_Printf ( " Compiled for AMD64 compatible cpus \n " ) ;
# endif
2009-04-19 05:01:55 +00:00
# ifdef _M_IX86
Con_Printf ( " x86 optimized for: " ) ;
2010-12-12 14:17:22 +00:00
if ( _M_IX86 = = 600 ) { Con_Printf ( " Blend or Pentium Pro, Pentium II and Pentium III " ) ; }
2009-04-19 05:01:55 +00:00
else if ( _M_IX86 = = 500 ) { Con_Printf ( " Pentium " ) ; }
else if ( _M_IX86 = = 400 ) { Con_Printf ( " 486 " ) ; }
else if ( _M_IX86 = = 300 ) { Con_Printf ( " 386 " ) ; }
else
{
Con_Printf ( " Unknown (%i) \n " , _M_IX86 ) ;
}
Con_Printf ( " \n " ) ;
# endif
# ifdef _M_IX86_FP
if ( _M_IX86_FP = = 0 ) { Con_Printf ( " SSE & SSE2 instructions disabled \n " ) ; }
else if ( _M_IX86_FP = = 1 ) { Con_Printf ( " SSE instructions enabled \n " ) ; }
else if ( _M_IX86_FP = = 2 ) { Con_Printf ( " SSE2 instructions enabled \n " ) ; }
else
{
Con_Printf ( " Unknown Arch specified: %i \n " , _M_IX86_FP ) ;
}
# endif
# ifdef _MSC_VER
if ( _MSC_VER = = 600 ) { Con_Printf ( " C Compiler version 6.0 \n " ) ; }
else if ( _MSC_VER = = 700 ) { Con_Printf ( " C/C++ compiler version 7.0 \n " ) ; }
else if ( _MSC_VER = = 800 ) { Con_Printf ( " Visual C++, Windows, version 1.0 or Visual C++, 32-bit, version 1.0 \n " ) ; }
else if ( _MSC_VER = = 900 ) { Con_Printf ( " Visual C++, Windows, version 2.0 or Visual C++, 32-bit, version 2.x \n " ) ; }
else if ( _MSC_VER = = 1000 ) { Con_Printf ( " Visual C++, 32-bit, version 4.0 \n " ) ; }
else if ( _MSC_VER = = 1020 ) { Con_Printf ( " Visual C++, 32-bit, version 4.2 \n " ) ; }
else if ( _MSC_VER = = 1100 ) { Con_Printf ( " Visual C++, 32-bit, version 5.0 \n " ) ; }
else if ( _MSC_VER = = 1200 ) { Con_Printf ( " Visual C++, 32-bit, version 6.0 \n " ) ; }
else if ( _MSC_VER = = 1300 ) { Con_Printf ( " Visual C++, version 7.0 \n " ) ; }
else if ( _MSC_VER = = 1310 ) { Con_Printf ( " Visual C++ 2003, version 7.1 \n " ) ; }
else if ( _MSC_VER = = 1400 ) { Con_Printf ( " Visual C++ 2005, version 8.0 \n " ) ; }
else if ( _MSC_VER = = 1500 ) { Con_Printf ( " Visual C++ 2008, version 9.0 \n " ) ; }
2010-11-10 05:35:14 +00:00
else if ( _MSC_VER = = 1600 ) { Con_Printf ( " Visual C++ 2010, version 10.0 \n " ) ; }
2009-04-19 05:01:55 +00:00
else
{
2009-05-24 10:28:26 +00:00
# ifdef _MSC_BUILD
Con_Printf ( " Unknown Microsoft C++ compiler: %i %i %i \n " , _MSC_VER , _MSC_FULL_VER , _MSC_BUILD ) ;
# else
Con_Printf ( " Unknown Microsoft C++ compiler: %i %i \n " , _MSC_VER , _MSC_FULL_VER ) ;
# endif
2009-04-19 05:01:55 +00:00
}
2009-07-19 03:51:07 +00:00
# endif
2012-11-27 03:23:19 +00:00
# ifdef MULTITHREAD
2014-10-05 20:04:11 +00:00
# ifdef LOADERTHREAD
Con_Printf ( " multithreading: enabled (loader enabled) \n " ) ;
# else
Con_Printf ( " multithreading: enabled (no loader) \n " ) ;
# endif
2012-11-27 03:23:19 +00:00
# else
Con_Printf ( " multithreading: disabled \n " ) ;
# endif
2009-07-19 03:51:07 +00:00
//print out which libraries are disabled
# ifndef AVAIL_ZLIB
Con_Printf ( " zlib disabled \n " ) ;
2010-11-11 09:06:36 +00:00
# else
Con_Printf ( " zlib: %s \n " , ZLIB_VERSION ) ;
2009-07-19 03:51:07 +00:00
# endif
2010-11-11 09:06:36 +00:00
2009-07-19 03:51:07 +00:00
# ifndef SERVERONLY
2014-10-05 20:04:11 +00:00
//but print client ones only if we're not dedicated
2009-07-19 03:51:07 +00:00
# ifndef AVAIL_PNGLIB
Con_Printf ( " libpng disabled \n " ) ;
2010-11-11 09:06:36 +00:00
# else
Con_Printf ( " libPNG %s -%s " , PNG_LIBPNG_VER_STRING , PNG_HEADER_VERSION_STRING ) ;
2009-07-19 03:51:07 +00:00
# endif
# ifndef AVAIL_JPEGLIB
Con_Printf ( " libjpeg disabled \n " ) ;
2010-11-11 09:06:36 +00:00
# else
2010-11-11 09:14:30 +00:00
Con_Printf ( " libjpeg: %i (%d series) \n " , JPEG_LIB_VERSION , ( JPEG_LIB_VERSION / 10 ) ) ;
2009-07-19 03:51:07 +00:00
# endif
2014-10-05 20:04:11 +00:00
Con_Printf ( " VoiceChat: " ) ;
# if !defined(VOICECHAT)
Con_Printf ( " disabled " ) ;
2012-11-27 03:23:19 +00:00
# else
2014-10-05 20:04:11 +00:00
# ifdef SPEEX_STATIC
Con_Printf ( " speex(static) " ) ;
# else
Con_Printf ( " speex(dynamic) " ) ;
# endif
# ifdef OPUS_STATIC
Con_Printf ( " opus(static) " ) ;
# else
Con_Printf ( " opus(dynamic) " ) ;
# endif
2012-11-27 03:23:19 +00:00
# endif
2014-10-05 20:04:11 +00:00
Con_Printf ( " \n " ) ;
Con_Printf ( " Audio Decoders: " ) ;
2012-11-27 03:23:19 +00:00
# ifndef AVAIL_OGGVORBIS
2014-10-05 20:04:11 +00:00
Con_Printf ( " ^h(disabled: Ogg Vorbis)^7 " ) ;
2012-11-27 03:23:19 +00:00
# elif defined(LIBVORBISFILE_STATIC)
2014-10-05 20:04:11 +00:00
Con_Printf ( " Ogg Vorbis(static) " ) ;
2012-11-27 03:23:19 +00:00
# else
2014-10-05 20:04:11 +00:00
Con_Printf ( " Ogg Vorbis(dynamic) " ) ;
# endif
# if defined(_WIN32) && !defined(WINRT) && !defined(NOMEDIA)
Con_Printf ( " mp3(system) " ) ;
# endif
Con_Printf ( " \n " ) ;
2012-11-27 03:23:19 +00:00
# endif
2014-10-05 20:04:11 +00:00
# ifdef SQL
Con_Printf ( " Databases: " ) ;
# ifdef USE_MYSQL
Con_Printf ( " mySQL(dynamic) " ) ;
# else
Con_Printf ( " ^h(disabled: mySQL)^7 " ) ;
# endif
# ifdef USE_SQLITE
Con_Printf ( " sqlite(dynamic) " ) ;
# else
Con_Printf ( " ^h(disabled: sqlite)^7 " ) ;
# endif
Con_Printf ( " \n " ) ;
# endif
Con_Printf ( " Misc: " ) ;
# ifdef ODE_STATIC
Con_Printf ( " ODE(static) " ) ;
# elif defined(USEODE)
Con_Printf ( " ODE(dynamic) " ) ;
2012-11-27 03:23:19 +00:00
# else
2014-10-05 20:04:11 +00:00
Con_Printf ( " ^h(disabled: ODE)^7 " ) ;
2012-11-27 03:23:19 +00:00
# endif
2014-10-05 20:04:11 +00:00
# ifdef SUBSERVERS
Con_Printf ( " mapcluster(enabled) " ) ;
2012-11-27 03:23:19 +00:00
# else
2014-10-05 20:04:11 +00:00
Con_Printf ( " ^h(disabled: mapcluster)^7 " ) ;
2012-11-27 03:23:19 +00:00
# endif
2014-10-05 20:04:11 +00:00
# ifndef SERVERONLY
# ifdef AVAIL_FREETYPE
Con_Printf ( " freetype2 " ) ;
# else
Con_Printf ( " ^h(disabled: freetype2)^7 " ) ;
2009-07-19 03:51:07 +00:00
# endif
2014-10-05 20:04:11 +00:00
# ifdef AVAIL_OPENAL
Con_Printf ( " openal " ) ;
# else
Con_Printf ( " ^h(disabled: openal)^7 " ) ;
2009-07-19 03:51:07 +00:00
# endif
2010-12-12 14:17:22 +00:00
# endif
2014-10-05 20:04:11 +00:00
Con_Printf ( " \n " ) ;
2010-12-12 14:17:22 +00:00
2009-07-19 03:51:07 +00:00
# ifdef _WIN32
# ifndef AVAIL_DINPUT
2010-12-12 14:17:22 +00:00
Con_Printf ( " DirectInput disabled \n " ) ;
2009-07-19 03:51:07 +00:00
# endif
# ifndef AVAIL_DSOUND
2010-12-12 14:17:22 +00:00
Con_Printf ( " DirectSound disabled \n " ) ;
# endif
# ifndef AVAIL_D3D
Con_Printf ( " Direct3D disabled \n " ) ;
# endif
# ifndef AVAIL_DDRAW
Con_Printf ( " DirectDraw disabled \n " ) ;
2009-07-19 03:51:07 +00:00
# endif
# endif
2014-10-05 20:04:11 +00:00
Con_Printf ( " Games: " ) ;
# if defined(Q3SERVER) && defined(Q3CLIENT)
Con_Printf ( " Quake3 " ) ;
# elif defined(Q3SERVER)
Con_Printf ( " Quake3(server) " ) ;
# elif defined(Q3CLIENT)
Con_Printf ( " Quake3(client) " ) ;
# elif defined(Q3BSPS)
Con_Printf ( " Quake3(bsp only) " ) ;
# else
Con_Printf ( " ^h(disabled: Quake3)^7 " ) ;
# endif
# if defined(Q2SERVER) && defined(Q2CLIENT)
Con_Printf ( " Quake2 " ) ;
# elif defined(Q2SERVER)
Con_Printf ( " Quake2(server) " ) ;
# elif defined(Q2CLIENT)
Con_Printf ( " Quake2(client) " ) ;
# elif defined(Q2BSPS)
Con_Printf ( " Quake2(bsp only) " ) ;
# else
Con_Printf ( " ^h(disabled: Quake2)^7 " ) ;
# endif
# if defined(HEXEN2)
Con_Printf ( " Hexen2 " ) ;
# else
Con_Printf ( " ^h(disabled: Hexen2)^7 " ) ;
# endif
# if defined(NQPROT)
Con_Printf ( " NetQuake " ) ;
# else
Con_Printf ( " ^h(disabled: NetQuake) " ) ;
# endif
# if defined(VM_Q1)
Con_Printf ( " ssq1qvm " ) ;
# endif
# if defined(VM_LUA)
Con_Printf ( " ssq1lua(dynamic) " ) ;
# endif
# if defined(MENU_DAT)
Con_Printf ( " menuqc " ) ;
# endif
# if defined(CSQC_DAT)
Con_Printf ( " csqc " ) ;
# endif
# ifndef CLIENTONLY
Con_Printf ( " ssqc " ) ;
2009-04-19 05:01:55 +00:00
# endif
2014-10-05 20:04:11 +00:00
Con_Printf ( " \n " ) ;
2009-02-22 13:50:17 +00:00
}
2004-08-21 01:25:48 +00:00
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
void COM_CrashMe_f ( void )
{
int * crashaddr = ( int * ) 0x05 ;
* crashaddr = 0 ;
}
2012-09-30 05:52:03 +00:00
void COM_ErrorMe_f ( void )
{
Sys_Error ( " \" errorme \" command used " ) ;
}
2014-10-05 20:04:11 +00:00
# ifdef LOADERTHREAD
/*multithreading worker thread stuff*/
static void * com_workercondition [ 2 ] ;
static qboolean com_workerdone [ 2 ] ;
static void * com_workerthread ;
static unsigned int mainthreadid ;
qboolean com_fatalerror ;
static struct com_work_s
{
struct com_work_s * next ;
void ( * func ) ( void * ctx , void * data , size_t a , size_t b ) ;
void * ctx ;
void * data ;
size_t a ;
size_t b ;
} * com_work_head [ 2 ] , * com_work_tail [ 2 ] ;
static void Sys_ErrorThread ( void * ctx , void * data , size_t a , size_t b )
{
Sys_Error ( data ) ;
}
void COM_WorkerAbort ( char * message )
{
struct com_work_s work ;
com_fatalerror = true ;
2014-10-14 16:42:48 +00:00
if ( Sys_IsMainThread ( ) )
2014-10-05 20:04:11 +00:00
return ;
work . func = Sys_ErrorThread ;
work . ctx = NULL ;
work . data = message ;
work . a = 0 ;
work . b = 0 ;
Sys_LockConditional ( com_workercondition [ 0 ] ) ;
if ( com_work_tail [ 0 ] )
{
com_work_tail [ 0 ] - > next = & work ;
com_work_tail [ 0 ] = & work ;
}
else
com_work_head [ 0 ] = com_work_tail [ 0 ] = & work ;
Sys_ConditionSignal ( com_workercondition [ 0 ] ) ;
Sys_UnlockConditional ( com_workercondition [ 0 ] ) ;
while ( com_fatalerror )
Sys_Sleep ( 0.1 ) ;
Sys_ThreadAbort ( ) ;
}
//return if there's *any* loading that needs to be done anywhere.
qboolean COM_HasWork ( void )
{
return com_work_head [ 0 ] | | com_work_head [ 1 ] ;
}
//thread==0 is main thread, thread==1 is a worker thread
void COM_AddWork ( int thread , void ( * func ) ( void * ctx , void * data , size_t a , size_t b ) , void * ctx , void * data , size_t a , size_t b )
{
//build the work
struct com_work_s * work = Z_Malloc ( sizeof ( * work ) ) ;
work - > func = func ;
work - > ctx = ctx ;
work - > data = data ;
work - > a = a ;
work - > b = b ;
if ( ! com_workerthread | | com_fatalerror )
thread = 0 ;
//queue it (fifo)
Sys_LockConditional ( com_workercondition [ thread ] ) ;
if ( com_work_tail [ thread ] )
{
com_work_tail [ thread ] - > next = work ;
com_work_tail [ thread ] = work ;
}
else
com_work_head [ thread ] = com_work_tail [ thread ] = work ;
// Sys_Printf("%x: Queued work %p (%s)\n", thread, work->ctx, work->ctx?(char*)work->ctx:"?");
Sys_ConditionSignal ( com_workercondition [ thread ] ) ;
Sys_UnlockConditional ( com_workercondition [ thread ] ) ;
if ( ! com_workerthread )
while ( COM_DoWork ( 0 , false ) )
;
}
//leavelocked = false == poll mode.
//leavelocked = true == safe sleeping
qboolean COM_DoWork ( int thread , qboolean leavelocked )
{
struct com_work_s * work ;
if ( ! leavelocked )
{
//skip the locks if it looks like we can be lazy.
if ( ! com_work_head [ thread ] )
return false ;
Sys_LockConditional ( com_workercondition [ thread ] ) ;
}
work = com_work_head [ thread ] ;
if ( work )
com_work_head [ thread ] = work - > next ;
if ( ! com_work_head [ thread ] )
com_work_head [ thread ] = com_work_tail [ thread ] = NULL ;
if ( work )
{
// Sys_Printf("%x: Doing work %p (%s)\n", thread, work->ctx, work->ctx?(char*)work->ctx:"?");
Sys_UnlockConditional ( com_workercondition [ thread ] ) ;
work - > func ( work - > ctx , work - > data , work - > a , work - > b ) ;
Z_Free ( work ) ;
if ( leavelocked )
Sys_LockConditional ( com_workercondition [ thread ] ) ;
return true ; //did something, check again
}
if ( ! leavelocked )
Sys_UnlockConditional ( com_workercondition [ thread ] ) ;
//nothing going on, if leavelocked then noone can add anything until we sleep.
return false ;
}
static int COM_WorkerThread ( void * arg )
{
int thread = * ( int * ) arg ;
Sys_LockConditional ( com_workercondition [ thread ] ) ;
do
{
while ( COM_DoWork ( thread , true ) )
;
if ( com_workerdone [ thread ] )
break ;
} while ( Sys_ConditionWait ( com_workercondition [ thread ] ) ) ;
Sys_UnlockConditional ( com_workercondition [ thread ] ) ;
return 0 ;
}
static void COM_WorkerSync_Stop ( void * ctx , void * data , size_t a , size_t b )
{
Sys_LockConditional ( com_workercondition [ a ] ) ;
com_workerdone [ a ] = true ;
Sys_ConditionSignal ( com_workercondition [ a ] ) ;
Sys_UnlockConditional ( com_workercondition [ a ] ) ;
}
# ifndef COM_AssertMainThread
void COM_AssertMainThread ( const char * msg )
{
2014-10-14 16:42:48 +00:00
if ( com_resourcemutex & & ! Sys_IsMainThread ( ) )
2014-10-05 20:04:11 +00:00
{
Sys_Error ( " Not on main thread: %s " , msg ) ;
}
}
# endif
void COM_DestroyWorkerThread ( void )
{
com_fatalerror = false ;
if ( com_workerthread )
{
//send it the terminate message
COM_AddWork ( 1 , COM_WorkerSync_Stop , NULL , NULL , 1 , 0 ) ;
Sys_WaitOnThread ( com_workerthread ) ;
com_workerthread = NULL ;
}
if ( com_workercondition [ 0 ] )
Sys_DestroyConditional ( com_workercondition [ 0 ] ) ;
com_workercondition [ 0 ] = NULL ;
if ( com_workercondition [ 1 ] )
Sys_DestroyConditional ( com_workercondition [ 1 ] ) ;
com_workercondition [ 1 ] = NULL ;
if ( com_resourcemutex )
Sys_DestroyMutex ( com_resourcemutex ) ;
com_resourcemutex = NULL ;
}
//partial means we're waiting for an explicit response. the caller will need to check when that response arrives.
void COM_WorkerFullSync ( void )
{
qboolean repeat ;
if ( ! com_workerthread )
return ;
//main thread asks worker thread to set main thread's 'done' flag.
//the worker might be posting work to the main thread and back (shaders with texures) so make sure that the only work we do before the reply is the reply itself.
do
{
int cmds = 0 ;
com_workerdone [ 0 ] = false ;
repeat = COM_HasWork ( ) ;
COM_AddWork ( 1 , COM_WorkerSync_Stop , NULL , NULL , 0 , 0 ) ;
Sys_LockConditional ( com_workercondition [ 0 ] ) ;
do
{
if ( com_fatalerror )
break ;
while ( COM_DoWork ( 0 , true ) )
cmds + + ;
if ( com_workerdone [ 0 ] )
break ;
} while ( Sys_ConditionWait ( com_workercondition [ 0 ] ) ) ;
Sys_UnlockConditional ( com_workercondition [ 0 ] ) ;
if ( com_fatalerror )
break ;
if ( cmds > 1 )
repeat = true ;
} while ( COM_DoWork ( 0 , false ) | | repeat ) ; //outer loop ensures there isn't anything pingponging between
}
//main thread wants a specific object to be prioritised.
//an ancestor of the work must be pending on either the main thread or the worker thread.
//typically the worker gives us a signal to handle the final activation of the object.
//the address should be the load status. the value is the current value.
//the work that we're waiting for will be considered complete when the address is no longer set to value.
void COM_WorkerPartialSync ( void * priorityctx , int * address , int value )
{
struct com_work_s * * link , * work , * prev ;
double time1 = Sys_DoubleTime ( ) ;
int thread = 1 ;
// Con_Printf("waiting for %p %s\n", priorityctx, priorityctx);
//boost the priority of the object that we're waiting for on the other thread, if we can find it.
//this avoids waiting for everything.
//if we can't find it, then its probably currently being processed anyway.
//main thread is meant to do all loadstate value changes anyway, ensuring that we're woken up properly in this case.
if ( priorityctx )
{
qboolean found = false ;
Sys_LockConditional ( com_workercondition [ thread ] ) ;
for ( link = & com_work_head [ thread ] , work = NULL ; * link ; link = & ( * link ) - > next )
{
prev = work ;
work = * link ;
if ( work - > ctx = = priorityctx )
{ //unlink it
* link = work - > next ;
if ( ! work - > next )
com_work_tail [ thread ] = prev ;
//link it in at the head, so its the next thing seen.
work - > next = com_work_head [ thread ] ;
com_work_head [ thread ] = work ;
if ( ! work - > next )
com_work_tail [ thread ] = work ;
found = true ;
break ; //found it, nothing else to do.
}
}
if ( ! found )
Con_DPrintf ( " Might be in for a long wait for %s \n " , priorityctx ) ;
//we've not actually added any work, so no need to signal
Sys_UnlockConditional ( com_workercondition [ thread ] ) ;
}
Sys_LockConditional ( com_workercondition [ 0 ] ) ;
do
{
if ( com_fatalerror )
break ;
while ( COM_DoWork ( 0 , true ) )
{
//give up as soon as we're done
if ( * address ! = value )
break ;
}
//if our object's state has changed, we're done
if ( * address ! = value )
break ;
} while ( Sys_ConditionWait ( com_workercondition [ 0 ] ) ) ;
Sys_UnlockConditional ( com_workercondition [ 0 ] ) ;
// Con_Printf("Waited %f for %s\n", Sys_DoubleTime() - time1, priorityctx);
}
static void COM_WorkerPing ( void * ctx , void * data , size_t a , size_t b )
{
double * timestamp = data ;
if ( ! b )
COM_AddWork ( 0 , COM_WorkerPing , ctx , data , 0 , 1 ) ;
else
{
Con_Printf ( " Ping: %g \n " , Sys_DoubleTime ( ) - * timestamp ) ;
}
}
static void COM_WorkerTest_f ( void )
{
if ( com_workerthread )
{
double * timestamp = Z_Malloc ( sizeof ( * timestamp ) ) ;
* timestamp = Sys_DoubleTime ( ) ;
COM_AddWork ( 1 , COM_WorkerPing , NULL , timestamp , 0 , 0 ) ;
}
else
Con_Printf ( " Worker is not active. \n " ) ;
}
cvar_t worker_flush = CVARD ( " worker_flush " , " 1 " , " Is set, process the entire load queue, loading stuff faster but at the risk of stalling. " ) ;
static void COM_InitWorkerThread ( void )
{
static int tid = 1 ;
//in theory, we could run multiple workers, signalling a different one in turn for each bit of work.
com_resourcemutex = Sys_CreateMutex ( ) ;
com_workercondition [ 0 ] = Sys_CreateConditional ( ) ;
com_workercondition [ 1 ] = Sys_CreateConditional ( ) ;
if ( ! COM_CheckParm ( " -noworker " ) )
com_workerthread = Sys_CreateThread ( " loadworker " , COM_WorkerThread , & tid , 0 , 256 * 1024 ) ;
Cmd_AddCommand ( " worker_test " , COM_WorkerTest_f ) ;
Cvar_Register ( & worker_flush , NULL ) ;
}
# endif
2004-08-21 01:25:48 +00:00
/*
= = = = = = = = = = = = = = = =
COM_Init
= = = = = = = = = = = = = = = =
*/
void COM_Init ( void )
{
qbyte swaptest [ 2 ] = { 1 , 0 } ;
2006-01-27 02:45:16 +00:00
// set the qbyte swapping variables in a portable manner
2004-08-21 01:25:48 +00:00
if ( * ( short * ) swaptest = = 1 )
{
2006-07-08 22:34:47 +00:00
bigendian = false ;
2004-08-21 01:25:48 +00:00
BigShort = ShortSwap ;
LittleShort = ShortNoSwap ;
BigLong = LongSwap ;
LittleLong = LongNoSwap ;
BigFloat = FloatSwap ;
LittleFloat = FloatNoSwap ;
}
else
{
2006-07-08 22:34:47 +00:00
bigendian = true ;
2004-08-21 01:25:48 +00:00
BigShort = ShortNoSwap ;
LittleShort = ShortSwap ;
BigLong = LongNoSwap ;
LittleLong = LongSwap ;
BigFloat = FloatNoSwap ;
LittleFloat = FloatSwap ;
}
2014-10-05 20:04:11 +00:00
# ifdef MULTITHREAD
Sys_ThreadsInit ( ) ;
# endif
# ifdef LOADERTHREAD
COM_InitWorkerThread ( ) ;
# endif
2005-01-04 07:49:23 +00:00
Cmd_AddCommand ( " path " , COM_Path_f ) ; //prints a list of current search paths.
Cmd_AddCommand ( " dir " , COM_Dir_f ) ; //q3 like
Cmd_AddCommand ( " flocate " , COM_Locate_f ) ; //prints the pak or whatever where this file can be found.
2009-02-22 13:50:17 +00:00
Cmd_AddCommand ( " version " , COM_Version_f ) ; //prints the pak or whatever where this file can be found.
2011-07-01 07:27:38 +00:00
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
Cmd_AddCommand ( " crashme " , COM_CrashMe_f ) ;
2012-09-30 05:52:03 +00:00
Cmd_AddCommand ( " errorme " , COM_ErrorMe_f ) ;
2004-08-21 01:25:48 +00:00
COM_InitFilesystem ( ) ;
2014-09-02 02:44:43 +00:00
Cvar_Register ( & sys_platform , " Gamecode " ) ;
2004-08-21 01:25:48 +00:00
Cvar_Register ( & registered , " Copy protection " ) ;
2008-11-09 22:29:28 +00:00
Cvar_Register ( & gameversion , " Gamecode " ) ;
2011-05-20 04:10:46 +00:00
Cvar_Register ( & gameversion_min , " Gamecode " ) ;
Cvar_Register ( & gameversion_max , " Gamecode " ) ;
2013-05-11 14:02:55 +00:00
Cvar_Register ( & com_nogamedirnativecode , " Gamecode " ) ;
2009-06-21 17:45:33 +00:00
Cvar_Register ( & com_parseutf8 , " Internationalisation " ) ;
2014-10-05 20:04:11 +00:00
Cvar_Register ( & com_parseezquake , NULL ) ;
2012-02-14 15:50:34 +00:00
Cvar_Register ( & com_highlightcolor , " Internationalisation " ) ;
2010-05-01 22:47:47 +00:00
com_parseutf8 . ival = 1 ;
2006-02-27 00:42:25 +00:00
2014-01-16 02:44:43 +00:00
TranslateInit ( ) ;
2006-02-27 00:42:25 +00:00
2014-06-30 21:57:35 +00:00
COM_BiDi_Setup ( ) ;
2006-02-27 00:42:25 +00:00
2013-10-29 17:38:22 +00:00
nullentitystate . hexen2flags = SCALE_ORIGIN_ORIGIN ;
2006-02-27 00:42:25 +00:00
nullentitystate . colormod [ 0 ] = 32 ;
nullentitystate . colormod [ 1 ] = 32 ;
nullentitystate . colormod [ 2 ] = 32 ;
2012-02-12 05:18:31 +00:00
nullentitystate . glowmod [ 0 ] = 32 ;
nullentitystate . glowmod [ 1 ] = 32 ;
nullentitystate . glowmod [ 2 ] = 32 ;
2006-02-27 00:42:25 +00:00
nullentitystate . trans = 255 ;
nullentitystate . scale = 16 ;
2012-02-12 05:18:31 +00:00
nullentitystate . solid = 0 ; //ES_SOLID_BSP;
2004-08-21 01:25:48 +00:00
}
/*
= = = = = = = = = = = =
va
does a varargs printf into a temp buffer , so I don ' t need to have
varargs versions of all text functions .
FIXME : make this buffer size safe someday
= = = = = = = = = = = =
*/
2013-11-29 14:36:47 +00:00
char * VARGS va ( const char * format , . . . )
2004-08-21 01:25:48 +00:00
{
# define VA_BUFFERS 2 //power of two
va_list argptr ;
static char string [ VA_BUFFERS ] [ 1024 ] ;
static int bufnum ;
2014-10-05 20:04:11 +00:00
COM_AssertMainThread ( " va " ) ;
2004-08-21 01:25:48 +00:00
bufnum + + ;
bufnum & = ( VA_BUFFERS - 1 ) ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
va_start ( argptr , format ) ;
2006-03-06 01:41:09 +00:00
vsnprintf ( string [ bufnum ] , sizeof ( string [ bufnum ] ) - 1 , format , argptr ) ;
2004-08-21 01:25:48 +00:00
va_end ( argptr ) ;
2006-01-27 02:45:16 +00:00
return string [ bufnum ] ;
2004-08-21 01:25:48 +00:00
}
/// just for debugging
int memsearch ( qbyte * start , int count , int search )
{
int i ;
2006-01-27 02:45:16 +00:00
2004-08-21 01:25:48 +00:00
for ( i = 0 ; i < count ; i + + )
if ( start [ i ] = = search )
return i ;
return - 1 ;
}
2014-03-30 08:55:06 +00:00
/*
2008-11-09 22:29:28 +00:00
struct effectinfo_s
{
struct effectinfo_s * next ;
int index ;
char name [ 1 ] ;
} ;
2008-11-28 20:34:51 +00:00
static struct effectinfo_s * effectinfo ;
static unsigned int lasteffectinfoid ;
2008-11-09 22:29:28 +00:00
2008-11-28 20:34:51 +00:00
void COM_Effectinfo_Clear ( void )
2008-11-09 22:29:28 +00:00
{
struct effectinfo_s * n ;
while ( effectinfo )
{
n = effectinfo - > next ;
Z_Free ( effectinfo ) ;
effectinfo = n ;
}
2008-11-28 20:34:51 +00:00
lasteffectinfoid = 0 ;
}
int COM_Effectinfo_Add ( const char * effectname )
{
struct effectinfo_s * n ;
for ( n = effectinfo ; n ; n = n - > next )
{
if ( ! strcmp ( effectname , n - > name ) )
return 0 ; //already known
}
n = Z_Malloc ( sizeof ( * n ) + strlen ( effectname ) ) ;
n - > next = effectinfo ;
n - > index = + + lasteffectinfoid ;
effectinfo = n ;
strcpy ( n - > name , effectname ) ;
return n - > index ;
}
void COM_Effectinfo_Reload ( void )
{
int i ;
2009-11-04 21:16:50 +00:00
char * f , * buf ;
2008-11-28 20:34:51 +00:00
static const char * dpnames [ ] =
{
" TE_GUNSHOT " ,
" TE_GUNSHOTQUAD " ,
" TE_SPIKE " ,
" TE_SPIKEQUAD " ,
" TE_SUPERSPIKE " ,
" TE_SUPERSPIKEQUAD " ,
" TE_WIZSPIKE " ,
" TE_KNIGHTSPIKE " ,
" TE_EXPLOSION " ,
" TE_EXPLOSIONQUAD " ,
" TE_TAREXPLOSION " ,
" TE_TELEPORT " ,
" TE_LAVASPLASH " ,
" TE_SMALLFLASH " ,
" TE_FLAMEJET " ,
" EF_FLAME " ,
" TE_BLOOD " ,
" TE_SPARK " ,
" TE_PLASMABURN " ,
" TE_TEI_G3 " ,
" TE_TEI_SMOKE " ,
" TE_TEI_BIGEXPLOSION " ,
" TE_TEI_PLASMAHIT " ,
" EF_STARDUST " ,
" TR_ROCKET " ,
" TR_GRENADE " ,
" TR_BLOOD " ,
" TR_WIZSPIKE " ,
" TR_SLIGHTBLOOD " ,
" TR_KNIGHTSPIKE " ,
" TR_VORESPIKE " ,
" TR_NEHAHRASMOKE " ,
" TR_NEXUIZPLASMA " ,
" TR_GLOWTRAIL " ,
" SVC_PARTICLE " ,
NULL
} ;
COM_Effectinfo_Clear ( ) ;
for ( i = 0 ; dpnames [ i ] ; i + + )
COM_Effectinfo_Add ( dpnames [ i ] ) ;
2008-11-09 22:29:28 +00:00
2011-05-19 13:34:07 +00:00
FS_LoadFile ( " effectinfo.txt " , ( void * * ) & f ) ;
2008-11-09 22:29:28 +00:00
if ( ! f )
return ;
2009-11-04 21:16:50 +00:00
buf = f ;
2012-11-27 03:23:19 +00:00
while ( f & & * f )
2008-11-09 22:29:28 +00:00
{
f = COM_ParseToken ( f , NULL ) ;
if ( strcmp ( com_token , " \n " ) )
{
if ( ! strcmp ( com_token , " effect " ) )
{
f = COM_ParseToken ( f , NULL ) ;
2008-11-28 20:34:51 +00:00
COM_Effectinfo_Add ( com_token ) ;
2008-11-09 22:29:28 +00:00
}
do
{
f = COM_ParseToken ( f , NULL ) ;
2012-11-27 03:23:19 +00:00
} while ( f & & * f & & strcmp ( com_token , " \n " ) ) ;
2008-11-09 22:29:28 +00:00
}
}
2009-11-04 21:16:50 +00:00
FS_FreeFile ( buf ) ;
2008-11-09 22:29:28 +00:00
}
2009-04-01 22:03:56 +00:00
unsigned int COM_Effectinfo_ForName ( const char * efname )
2008-11-09 22:29:28 +00:00
{
struct effectinfo_s * e ;
2004-08-21 01:25:48 +00:00
2008-11-09 22:29:28 +00:00
if ( ! effectinfo )
2008-11-28 20:34:51 +00:00
COM_Effectinfo_Reload ( ) ;
2004-08-21 01:25:48 +00:00
2008-11-09 22:29:28 +00:00
for ( e = effectinfo ; e ; e = e - > next )
{
if ( ! strcmp ( efname , e - > name ) )
return e - > index ;
}
2008-11-28 20:34:51 +00:00
return COM_Effectinfo_Add ( efname ) ;
2008-11-09 22:29:28 +00:00
}
char * COM_Effectinfo_ForNumber ( unsigned int efnum )
{
struct effectinfo_s * e ;
if ( ! effectinfo )
2008-11-28 20:34:51 +00:00
COM_Effectinfo_Reload ( ) ;
2008-11-09 22:29:28 +00:00
for ( e = effectinfo ; e ; e = e - > next )
{
if ( e - > index = = efnum )
return e - > name ;
}
return " " ;
}
2014-03-30 08:55:06 +00:00
*/
2009-11-04 21:16:50 +00:00
/*************************************************************************/
/*remaps map checksums from known non-cheat GPL maps to authentic id1 maps*/
unsigned int COM_RemapMapChecksum ( unsigned int checksum )
{
static const struct {
char * name ;
unsigned int gpl2 ;
unsigned int id11 ;
unsigned int id12 ;
2010-11-10 05:35:14 +00:00
} sums [ ] =
2009-11-04 21:16:50 +00:00
{
{ " maps/start.bsp " , - 603735309 , 714749795 , 493454459 } ,
{ " maps/e1m1.bsp " , - 1213097692 , 523840258 , - 1391994750 } ,
2010-11-10 05:35:14 +00:00
{ " maps/e1m2.bsp " , - 2134038629 , 1561595172 , 1729102119 } ,
2009-11-04 21:16:50 +00:00
{ " maps/e1m3.bsp " , 526593427 , 1008794158 , 893792842 } ,
{ " maps/e1m4.bsp " , - 1218723400 , - 442162482 , - 304478603 } ,
{ " maps/e1m5.bsp " , 1709090059 , 1856217547 , - 1473504118 } ,
{ " maps/e1m6.bsp " , 1014375998 , 1304756164 , 738207971 } ,
{ " maps/e1m7.bsp " , 1375393448 , - 1396746908 , - 1747518694 } ,
{ " maps/e1m8.bsp " , 1470379688 , - 163803419 , 79095617 } ,
{ " maps/e2m1.bsp " , - 1725230579 , - 797758554 , - 587894734 } ,
{ " maps/e2m2.bsp " , - 1573837115 , - 355822557 , - 1349116595 } ,
{ " maps/e2m3.bsp " , 156655662 , 1203005272 , - 57072303 } ,
{ " maps/e2m4.bsp " , - 1530012474 , - 1629664024 , - 1021928503 } ,
{ " maps/e3m5.bsp " , - 594001393 , - 1405673977 , - 1854273999 } ,
{ " maps/e2m6.bsp " , 1041933133 , 583875451 , - 1851573375 } ,
{ " maps/e2m7.bsp " , - 1583122652 , 1814005234 , 2051006488 } ,
{ " maps/e3m1.bsp " , - 1118143869 , - 457270773 , - 1867379423 } ,
{ " maps/e3m2.bsp " , - 469484146 , 723435606 , - 1670613704 } ,
{ " maps/e3m3.bsp " , - 300762423 , - 540030088 , - 1009754856 } ,
{ " maps/e3m4.bsp " , - 214067894 , 1107310161 , - 1317466952 } ,
{ " maps/e3m5.bsp " , - 594001393 , - 1405673977 , - 1854273999 } ,
{ " maps/e3m6.bsp " , - 1664550468 , 1631142730 , 767655416 } ,
{ " maps/e3m7.bsp " , 781051658 , - 1513131760 , 272220593 } ,
{ " maps/e4m1.bsp " , 1548541253 , 1254243660 , - 1141873840 } ,
{ " maps/e4m2.bsp " , - 1400585206 , 92253388 , - 472296 } ,
{ " maps/e4m3.bsp " , - 1230693918 , 1961442781 , 1505685644 } ,
{ " maps/e4m4.bsp " , 842253404 , - 374904516 , 758847551 } ,
{ " maps/e4m5.bsp " , - 439098147 , 389110272 , 1771890676 } ,
{ " maps/e4m6.bsp " , 1518024640 , 1714857656 , 102825880 } ,
{ " maps/e4m7.bsp " , - 381063035 , - 585362206 , - 1645477460 } ,
{ " maps/e4m8.bsp " , 844770132 , 1063417045 , 1018457175 } ,
{ " maps/gpl_dm1.bsp " , 2100781454 , - 1548219590 , - 976758093 } ,
{ " maps/gpl_dm2.bsp " , 2066969664 , 392410074 , 1710634548 } ,
{ " maps/gpl_dm3.bsp " , - 1859681874 , 2060033246 , 367136248 } ,
{ " maps/gpl_dm4.bsp " , - 1015750775 , 326737183 , - 1670388545 } ,
{ " maps/gpl_dm5.bsp " , 2009758949 , 766929852 , - 1339209475 } ,
{ " maps/gpl_dm6.bsp " , 537693021 , 247150701 , 1376311851 } ,
{ " maps/end.bsp " , - 124054866 , - 1503553320 , - 1143688027 }
} ;
unsigned int i ;
for ( i = 0 ; i < sizeof ( sums ) / sizeof ( sums [ 0 ] ) ; i + + )
{
if ( checksum = = sums [ i ] . gpl2 )
return sums [ i ] . id12 ;
}
return checksum ;
}
2004-08-21 01:25:48 +00:00
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
INFO STRINGS
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
/*
= = = = = = = = = = = = = = =
Info_ValueForKey
Searches the string for the given
key and returns the associated value , or an empty string .
= = = = = = = = = = = = = = =
*/
2014-03-30 08:55:06 +00:00
char * Info_ValueForKey ( const char * s , const char * key )
2004-08-21 01:25:48 +00:00
{
char pkey [ 1024 ] ;
static char value [ 4 ] [ 1024 ] ; // use two buffers so compares
// work without stomping on each other
static int valueindex ;
char * o ;
2006-01-27 02:45:16 +00:00
2014-10-05 20:04:11 +00:00
COM_AssertMainThread ( " Info_ValueForKey " ) ;
2004-08-21 01:25:48 +00:00
valueindex = ( valueindex + 1 ) % 4 ;
if ( * s = = ' \\ ' )
s + + ;
while ( 1 )
{
o = pkey ;
while ( * s ! = ' \\ ' )
{
if ( ! * s )
{
* value [ valueindex ] = ' \0 ' ;
return value [ valueindex ] ;
}
* o + + = * s + + ;
2004-12-05 11:39:39 +00:00
if ( o + 2 > = pkey + sizeof ( pkey ) ) //hrm. hackers at work..
{
* value [ valueindex ] = ' \0 ' ;
return value [ valueindex ] ;
}
2004-08-21 01:25:48 +00:00
}
* o = 0 ;
s + + ;
o = value [ valueindex ] ;
while ( * s ! = ' \\ ' & & * s )
{
if ( ! * s )
{
* value [ valueindex ] = ' \0 ' ;
return value [ valueindex ] ;
}
* o + + = * s + + ;
2006-01-27 02:45:16 +00:00
2004-12-05 11:39:39 +00:00
if ( o + 2 > = value [ valueindex ] + sizeof ( value [ valueindex ] ) ) //hrm. hackers at work..
{
* value [ valueindex ] = ' \0 ' ;
return value [ valueindex ] ;
}
2004-08-21 01:25:48 +00:00
}
* o = 0 ;
if ( ! strcmp ( key , pkey ) )
return value [ valueindex ] ;
if ( ! * s )
{
* value [ valueindex ] = ' \0 ' ;
return value [ valueindex ] ;
}
s + + ;
}
}
2005-10-01 03:09:17 +00:00
char * Info_KeyForNumber ( char * s , int num )
{
static char pkey [ 1024 ] ;
char * o ;
2006-01-27 02:45:16 +00:00
2005-10-01 03:09:17 +00:00
if ( * s = = ' \\ ' )
s + + ;
while ( 1 )
{
o = pkey ;
while ( * s ! = ' \\ ' )
{
if ( ! * s )
{
* pkey = ' \0 ' ;
return pkey ;
}
* o + + = * s + + ;
if ( o + 2 > = pkey + sizeof ( pkey ) ) //hrm. hackers at work..
{
* pkey = ' \0 ' ;
return pkey ;
}
}
* o = 0 ;
s + + ;
while ( * s ! = ' \\ ' & & * s )
{
if ( ! * s )
{
* pkey = ' \0 ' ;
return pkey ;
}
s + + ;
}
if ( ! num - - )
return pkey ; //found the right one
if ( ! * s )
{
* pkey = ' \0 ' ;
return pkey ;
}
s + + ;
}
}
2005-03-28 00:11:59 +00:00
void Info_RemoveKey ( char * s , const char * key )
2004-08-21 01:25:48 +00:00
{
char * start ;
char pkey [ 1024 ] ;
char value [ 1024 ] ;
char * o ;
if ( strstr ( key , " \\ " ) )
{
2013-11-21 23:02:28 +00:00
Con_Printf ( " Can't use a key with a \\ \n " ) ;
2004-08-21 01:25:48 +00:00
return ;
}
while ( 1 )
{
start = s ;
if ( * s = = ' \\ ' )
s + + ;
o = pkey ;
while ( * s ! = ' \\ ' )
{
if ( ! * s )
return ;
* o + + = * s + + ;
}
* o = 0 ;
s + + ;
o = value ;
while ( * s ! = ' \\ ' & & * s )
{
if ( ! * s )
return ;
* o + + = * s + + ;
}
* o = 0 ;
if ( ! strcmp ( key , pkey ) )
{
2007-07-23 10:59:48 +00:00
//strip out the value by copying the next string over the top of this one
//(we were using strcpy, but valgrind moaned)
while ( * s )
* start + + = * s + + ;
* start = 0 ;
2004-08-21 01:25:48 +00:00
return ;
}
if ( ! * s )
return ;
}
}
void Info_RemovePrefixedKeys ( char * start , char prefix )
{
char * s ;
char pkey [ 1024 ] ;
char value [ 1024 ] ;
char * o ;
s = start ;
while ( 1 )
{
if ( * s = = ' \\ ' )
s + + ;
o = pkey ;
while ( * s ! = ' \\ ' )
{
if ( ! * s )
return ;
* o + + = * s + + ;
}
* o = 0 ;
s + + ;
o = value ;
while ( * s ! = ' \\ ' & & * s )
{
if ( ! * s )
return ;
* o + + = * s + + ;
}
* o = 0 ;
if ( pkey [ 0 ] = = prefix )
{
Info_RemoveKey ( start , pkey ) ;
s = start ;
}
if ( ! * s )
return ;
}
}
void Info_RemoveNonStarKeys ( char * start )
{
char * s ;
char pkey [ 1024 ] ;
char value [ 1024 ] ;
char * o ;
s = start ;
while ( 1 )
{
if ( * s = = ' \\ ' )
s + + ;
o = pkey ;
while ( * s ! = ' \\ ' )
{
if ( ! * s )
return ;
* o + + = * s + + ;
}
* o = 0 ;
s + + ;
o = value ;
while ( * s ! = ' \\ ' & & * s )
{
if ( ! * s )
return ;
* o + + = * s + + ;
}
* o = 0 ;
if ( pkey [ 0 ] ! = ' * ' )
{
Info_RemoveKey ( start , pkey ) ;
s = start ;
}
if ( ! * s )
return ;
}
}
2005-03-28 00:11:59 +00:00
void Info_SetValueForStarKey ( char * s , const char * key , const char * value , int maxsize )
2004-08-21 01:25:48 +00:00
{
2005-03-28 00:11:59 +00:00
char newv [ 1024 ] , * v ;
2004-08-21 01:25:48 +00:00
int c ;
# ifdef SERVERONLY
extern cvar_t sv_highchars ;
# endif
if ( strstr ( key , " \\ " ) | | strstr ( value , " \\ " ) )
{
2013-11-21 23:02:28 +00:00
Con_Printf ( " Can't use a key with a \\ \n " ) ;
2004-08-21 01:25:48 +00:00
return ;
}
if ( strstr ( key , " \" " ) | | strstr ( value , " \" " ) )
{
2013-11-21 23:02:28 +00:00
Con_Printf ( " Can't use a key with a \" \n " ) ;
2004-08-21 01:25:48 +00:00
return ;
}
2006-01-02 22:58:16 +00:00
if ( strlen ( key ) > = MAX_INFO_KEY ) // || strlen(value) >= MAX_INFO_KEY)
2004-08-21 01:25:48 +00:00
{
2013-11-21 23:02:28 +00:00
Con_Printf ( " Keys and values must be < %i characters. \n " , MAX_INFO_KEY ) ;
2004-08-21 01:25:48 +00:00
return ;
}
// this next line is kinda trippy
if ( * ( v = Info_ValueForKey ( s , key ) ) )
{
// key exists, make sure we have enough room for new value, if we don't,
// don't change it!
if ( strlen ( value ) - strlen ( v ) + strlen ( s ) + 1 > maxsize )
{
if ( * Info_ValueForKey ( s , " *ver " ) ) //quick hack to kill off unneeded info on overflow. We can't simply increase the quantity of this stuff.
{
Info_RemoveKey ( s , " *ver " ) ;
Info_SetValueForStarKey ( s , key , value , maxsize ) ;
return ;
}
2013-11-21 23:02:28 +00:00
Con_Printf ( " Info string length exceeded on addition of %s \n " , key ) ;
2004-08-21 01:25:48 +00:00
return ;
}
}
Info_RemoveKey ( s , key ) ;
if ( ! value | | ! strlen ( value ) )
return ;
2006-03-06 01:41:09 +00:00
snprintf ( newv , sizeof ( newv ) , " \\ %s \\ %s " , key , value ) ;
2004-08-21 01:25:48 +00:00
2005-03-28 00:11:59 +00:00
if ( ( int ) ( strlen ( newv ) + strlen ( s ) + 1 ) > maxsize )
2004-08-21 01:25:48 +00:00
{
2013-11-21 23:02:28 +00:00
Con_Printf ( " Info string length exceeded on addition of %s \n " , key ) ;
2004-08-21 01:25:48 +00:00
return ;
}
// only copy ascii values
s + = strlen ( s ) ;
2005-03-28 00:11:59 +00:00
v = newv ;
2004-08-21 01:25:48 +00:00
while ( * v )
{
c = ( unsigned char ) * v + + ;
# ifndef SERVERONLY
// client only allows highbits on name
2007-09-05 22:36:23 +00:00
// if (stricmp(key, "name") != 0) {
// c &= 127;
// if (c < 32 || c > 127)
// continue;
// // auto lowercase team
// if (stricmp(key, "team") == 0)
// c = tolower(c);
// }
2004-08-21 01:25:48 +00:00
# else
if ( ! sv_highchars . value ) {
c & = 127 ;
if ( c < 32 | | c > 127 )
continue ;
}
# endif
// c &= 127; // strip high bits
if ( c > 13 ) // && c < 127)
* s + + = c ;
}
* s = 0 ;
}
2005-03-28 00:11:59 +00:00
void Info_SetValueForKey ( char * s , const char * key , const char * value , int maxsize )
2004-08-21 01:25:48 +00:00
{
if ( key [ 0 ] = = ' * ' )
{
2013-11-21 23:02:28 +00:00
Con_Printf ( " Can't set * keys \n " ) ;
2004-08-21 01:25:48 +00:00
return ;
}
Info_SetValueForStarKey ( s , key , value , maxsize ) ;
}
2013-06-23 02:17:02 +00:00
void Info_Print ( char * s , char * lineprefix )
2004-08-21 01:25:48 +00:00
{
char key [ 1024 ] ;
char value [ 1024 ] ;
char * o ;
int l ;
if ( * s = = ' \\ ' )
s + + ;
while ( * s )
{
o = key ;
while ( * s & & * s ! = ' \\ ' )
* o + + = * s + + ;
l = o - key ;
if ( l < 20 )
{
memset ( o , ' ' , 20 - l ) ;
key [ 20 ] = 0 ;
}
else
* o = 0 ;
2013-06-23 02:17:02 +00:00
Con_Printf ( " %s%s " , lineprefix , key ) ;
2004-08-21 01:25:48 +00:00
if ( ! * s )
{
2013-11-21 23:02:28 +00:00
//should never happen.
Con_Printf ( " <no value> \n " ) ;
2004-08-21 01:25:48 +00:00
return ;
}
o = value ;
s + + ;
while ( * s & & * s ! = ' \\ ' )
* o + + = * s + + ;
* o = 0 ;
if ( * s )
s + + ;
Con_Printf ( " %s \n " , value ) ;
}
}
2005-12-21 03:07:33 +00:00
void Info_WriteToFile ( vfsfile_t * f , char * info , char * commandname , int cvarflags )
2005-11-30 01:20:53 +00:00
{
char * command ;
char * value ;
cvar_t * var ;
while ( * info = = ' \\ ' )
{
command = info + 1 ;
value = strchr ( command , ' \\ ' ) ;
info = strchr ( value + 1 , ' \\ ' ) ;
if ( ! info ) //eot..
info = value + strlen ( value ) ;
if ( * command = = ' * ' ) //unsettable, so don't write it for later setting.
continue ;
var = Cvar_FindVar ( command ) ;
if ( var & & var - > flags & cvarflags )
continue ; //this is saved via a cvar.
2005-12-21 03:07:33 +00:00
VFS_WRITE ( f , commandname , strlen ( commandname ) ) ;
VFS_WRITE ( f , " " , 1 ) ;
VFS_WRITE ( f , command , value - command ) ;
VFS_WRITE ( f , " " , 1 ) ;
VFS_WRITE ( f , value + 1 , info - ( value + 1 ) ) ;
VFS_WRITE ( f , " \n " , 1 ) ;
2005-11-30 01:20:53 +00:00
}
}
2004-08-21 01:25:48 +00:00
static qbyte chktbl [ 1024 + 4 ] = {
0x78 , 0xd2 , 0x94 , 0xe3 , 0x41 , 0xec , 0xd6 , 0xd5 , 0xcb , 0xfc , 0xdb , 0x8a , 0x4b , 0xcc , 0x85 , 0x01 ,
0x23 , 0xd2 , 0xe5 , 0xf2 , 0x29 , 0xa7 , 0x45 , 0x94 , 0x4a , 0x62 , 0xe3 , 0xa5 , 0x6f , 0x3f , 0xe1 , 0x7a ,
0x64 , 0xed , 0x5c , 0x99 , 0x29 , 0x87 , 0xa8 , 0x78 , 0x59 , 0x0d , 0xaa , 0x0f , 0x25 , 0x0a , 0x5c , 0x58 ,
0xfb , 0x00 , 0xa7 , 0xa8 , 0x8a , 0x1d , 0x86 , 0x80 , 0xc5 , 0x1f , 0xd2 , 0x28 , 0x69 , 0x71 , 0x58 , 0xc3 ,
0x51 , 0x90 , 0xe1 , 0xf8 , 0x6a , 0xf3 , 0x8f , 0xb0 , 0x68 , 0xdf , 0x95 , 0x40 , 0x5c , 0xe4 , 0x24 , 0x6b ,
0x29 , 0x19 , 0x71 , 0x3f , 0x42 , 0x63 , 0x6c , 0x48 , 0xe7 , 0xad , 0xa8 , 0x4b , 0x91 , 0x8f , 0x42 , 0x36 ,
0x34 , 0xe7 , 0x32 , 0x55 , 0x59 , 0x2d , 0x36 , 0x38 , 0x38 , 0x59 , 0x9b , 0x08 , 0x16 , 0x4d , 0x8d , 0xf8 ,
0x0a , 0xa4 , 0x52 , 0x01 , 0xbb , 0x52 , 0xa9 , 0xfd , 0x40 , 0x18 , 0x97 , 0x37 , 0xff , 0xc9 , 0x82 , 0x27 ,
0xb2 , 0x64 , 0x60 , 0xce , 0x00 , 0xd9 , 0x04 , 0xf0 , 0x9e , 0x99 , 0xbd , 0xce , 0x8f , 0x90 , 0x4a , 0xdd ,
0xe1 , 0xec , 0x19 , 0x14 , 0xb1 , 0xfb , 0xca , 0x1e , 0x98 , 0x0f , 0xd4 , 0xcb , 0x80 , 0xd6 , 0x05 , 0x63 ,
0xfd , 0xa0 , 0x74 , 0xa6 , 0x86 , 0xf6 , 0x19 , 0x98 , 0x76 , 0x27 , 0x68 , 0xf7 , 0xe9 , 0x09 , 0x9a , 0xf2 ,
0x2e , 0x42 , 0xe1 , 0xbe , 0x64 , 0x48 , 0x2a , 0x74 , 0x30 , 0xbb , 0x07 , 0xcc , 0x1f , 0xd4 , 0x91 , 0x9d ,
0xac , 0x55 , 0x53 , 0x25 , 0xb9 , 0x64 , 0xf7 , 0x58 , 0x4c , 0x34 , 0x16 , 0xbc , 0xf6 , 0x12 , 0x2b , 0x65 ,
0x68 , 0x25 , 0x2e , 0x29 , 0x1f , 0xbb , 0xb9 , 0xee , 0x6d , 0x0c , 0x8e , 0xbb , 0xd2 , 0x5f , 0x1d , 0x8f ,
0xc1 , 0x39 , 0xf9 , 0x8d , 0xc0 , 0x39 , 0x75 , 0xcf , 0x25 , 0x17 , 0xbe , 0x96 , 0xaf , 0x98 , 0x9f , 0x5f ,
0x65 , 0x15 , 0xc4 , 0x62 , 0xf8 , 0x55 , 0xfc , 0xab , 0x54 , 0xcf , 0xdc , 0x14 , 0x06 , 0xc8 , 0xfc , 0x42 ,
0xd3 , 0xf0 , 0xad , 0x10 , 0x08 , 0xcd , 0xd4 , 0x11 , 0xbb , 0xca , 0x67 , 0xc6 , 0x48 , 0x5f , 0x9d , 0x59 ,
0xe3 , 0xe8 , 0x53 , 0x67 , 0x27 , 0x2d , 0x34 , 0x9e , 0x9e , 0x24 , 0x29 , 0xdb , 0x69 , 0x99 , 0x86 , 0xf9 ,
0x20 , 0xb5 , 0xbb , 0x5b , 0xb0 , 0xf9 , 0xc3 , 0x67 , 0xad , 0x1c , 0x9c , 0xf7 , 0xcc , 0xef , 0xce , 0x69 ,
0xe0 , 0x26 , 0x8f , 0x79 , 0xbd , 0xca , 0x10 , 0x17 , 0xda , 0xa9 , 0x88 , 0x57 , 0x9b , 0x15 , 0x24 , 0xba ,
0x84 , 0xd0 , 0xeb , 0x4d , 0x14 , 0xf5 , 0xfc , 0xe6 , 0x51 , 0x6c , 0x6f , 0x64 , 0x6b , 0x73 , 0xec , 0x85 ,
0xf1 , 0x6f , 0xe1 , 0x67 , 0x25 , 0x10 , 0x77 , 0x32 , 0x9e , 0x85 , 0x6e , 0x69 , 0xb1 , 0x83 , 0x00 , 0xe4 ,
0x13 , 0xa4 , 0x45 , 0x34 , 0x3b , 0x40 , 0xff , 0x41 , 0x82 , 0x89 , 0x79 , 0x57 , 0xfd , 0xd2 , 0x8e , 0xe8 ,
0xfc , 0x1d , 0x19 , 0x21 , 0x12 , 0x00 , 0xd7 , 0x66 , 0xe5 , 0xc7 , 0x10 , 0x1d , 0xcb , 0x75 , 0xe8 , 0xfa ,
0xb6 , 0xee , 0x7b , 0x2f , 0x1a , 0x25 , 0x24 , 0xb9 , 0x9f , 0x1d , 0x78 , 0xfb , 0x84 , 0xd0 , 0x17 , 0x05 ,
0x71 , 0xb3 , 0xc8 , 0x18 , 0xff , 0x62 , 0xee , 0xed , 0x53 , 0xab , 0x78 , 0xd3 , 0x65 , 0x2d , 0xbb , 0xc7 ,
0xc1 , 0xe7 , 0x70 , 0xa2 , 0x43 , 0x2c , 0x7c , 0xc7 , 0x16 , 0x04 , 0xd2 , 0x45 , 0xd5 , 0x6b , 0x6c , 0x7a ,
0x5e , 0xa1 , 0x50 , 0x2e , 0x31 , 0x5b , 0xcc , 0xe8 , 0x65 , 0x8b , 0x16 , 0x85 , 0xbf , 0x82 , 0x83 , 0xfb ,
0xde , 0x9f , 0x36 , 0x48 , 0x32 , 0x79 , 0xd6 , 0x9b , 0xfb , 0x52 , 0x45 , 0xbf , 0x43 , 0xf7 , 0x0b , 0x0b ,
0x19 , 0x19 , 0x31 , 0xc3 , 0x85 , 0xec , 0x1d , 0x8c , 0x20 , 0xf0 , 0x3a , 0xfa , 0x80 , 0x4d , 0x2c , 0x7d ,
0xac , 0x60 , 0x09 , 0xc0 , 0x40 , 0xee , 0xb9 , 0xeb , 0x13 , 0x5b , 0xe8 , 0x2b , 0xb1 , 0x20 , 0xf0 , 0xce ,
0x4c , 0xbd , 0xc6 , 0x04 , 0x86 , 0x70 , 0xc6 , 0x33 , 0xc3 , 0x15 , 0x0f , 0x65 , 0x19 , 0xfd , 0xc2 , 0xd3 ,
// map checksum goes here
0x00 , 0x00 , 0x00 , 0x00
} ;
#if 0
static qbyte chkbuf [ 16 + 60 + 4 ] ;
static unsigned last_mapchecksum = 0 ;
/*
= = = = = = = = = = = = = = = = = = = =
COM_BlockSequenceCheckByte
For proxy protecting
= = = = = = = = = = = = = = = = = = = =
*/
qbyte COM_BlockSequenceCheckByte ( qbyte * base , int length , int sequence , unsigned mapchecksum )
{
int checksum ;
qbyte * p ;
if ( last_mapchecksum ! = mapchecksum ) {
last_mapchecksum = mapchecksum ;
chktbl [ 1024 ] = ( mapchecksum & 0xff000000 ) > > 24 ;
chktbl [ 1025 ] = ( mapchecksum & 0x00ff0000 ) > > 16 ;
chktbl [ 1026 ] = ( mapchecksum & 0x0000ff00 ) > > 8 ;
chktbl [ 1027 ] = ( mapchecksum & 0x000000ff ) ;
Com_BlockFullChecksum ( chktbl , sizeof ( chktbl ) , chkbuf ) ;
}
p = chktbl + ( sequence % ( sizeof ( chktbl ) - 8 ) ) ;
if ( length > 60 )
length = 60 ;
memcpy ( chkbuf + 16 , base , length ) ;
length + = 16 ;
chkbuf [ length ] = ( sequence & 0xff ) ^ p [ 0 ] ;
chkbuf [ length + 1 ] = p [ 1 ] ;
chkbuf [ length + 2 ] = ( ( sequence > > 8 ) & 0xff ) ^ p [ 2 ] ;
chkbuf [ length + 3 ] = p [ 3 ] ;
length + = 4 ;
checksum = LittleLong ( Com_BlockChecksum ( chkbuf , length ) ) ;
checksum & = 0xff ;
return checksum ;
}
# endif
/*
= = = = = = = = = = = = = = = = = = = =
COM_BlockSequenceCRCByte
For proxy protecting
= = = = = = = = = = = = = = = = = = = =
*/
qbyte COM_BlockSequenceCRCByte ( qbyte * base , int length , int sequence )
{
unsigned short crc ;
qbyte * p ;
qbyte chkb [ 60 + 4 ] ;
p = chktbl + ( sequence % ( sizeof ( chktbl ) - 8 ) ) ;
if ( length > 60 )
length = 60 ;
memcpy ( chkb , base , length ) ;
chkb [ length ] = ( sequence & 0xff ) ^ p [ 0 ] ;
chkb [ length + 1 ] = p [ 1 ] ;
chkb [ length + 2 ] = ( ( sequence > > 8 ) & 0xff ) ^ p [ 2 ] ;
chkb [ length + 3 ] = p [ 3 ] ;
length + = 4 ;
2005-09-08 22:52:46 +00:00
crc = QCRC_Block ( chkb , length ) ;
2004-08-21 01:25:48 +00:00
crc & = 0xff ;
return crc ;
}
# if defined(Q2CLIENT) || defined(Q2SERVER)
static qbyte q2chktbl [ 1024 ] = {
0x84 , 0x47 , 0x51 , 0xc1 , 0x93 , 0x22 , 0x21 , 0x24 , 0x2f , 0x66 , 0x60 , 0x4d , 0xb0 , 0x7c , 0xda ,
0x88 , 0x54 , 0x15 , 0x2b , 0xc6 , 0x6c , 0x89 , 0xc5 , 0x9d , 0x48 , 0xee , 0xe6 , 0x8a , 0xb5 , 0xf4 ,
0xcb , 0xfb , 0xf1 , 0x0c , 0x2e , 0xa0 , 0xd7 , 0xc9 , 0x1f , 0xd6 , 0x06 , 0x9a , 0x09 , 0x41 , 0x54 ,
0x67 , 0x46 , 0xc7 , 0x74 , 0xe3 , 0xc8 , 0xb6 , 0x5d , 0xa6 , 0x36 , 0xc4 , 0xab , 0x2c , 0x7e , 0x85 ,
0xa8 , 0xa4 , 0xa6 , 0x4d , 0x96 , 0x19 , 0x19 , 0x9a , 0xcc , 0xd8 , 0xac , 0x39 , 0x5e , 0x3c , 0xf2 ,
0xf5 , 0x5a , 0x72 , 0xe5 , 0xa9 , 0xd1 , 0xb3 , 0x23 , 0x82 , 0x6f , 0x29 , 0xcb , 0xd1 , 0xcc , 0x71 ,
0xfb , 0xea , 0x92 , 0xeb , 0x1c , 0xca , 0x4c , 0x70 , 0xfe , 0x4d , 0xc9 , 0x67 , 0x43 , 0x47 , 0x94 ,
0xb9 , 0x47 , 0xbc , 0x3f , 0x01 , 0xab , 0x7b , 0xa6 , 0xe2 , 0x76 , 0xef , 0x5a , 0x7a , 0x29 , 0x0b ,
0x51 , 0x54 , 0x67 , 0xd8 , 0x1c , 0x14 , 0x3e , 0x29 , 0xec , 0xe9 , 0x2d , 0x48 , 0x67 , 0xff , 0xed ,
0x54 , 0x4f , 0x48 , 0xc0 , 0xaa , 0x61 , 0xf7 , 0x78 , 0x12 , 0x03 , 0x7a , 0x9e , 0x8b , 0xcf , 0x83 ,
0x7b , 0xae , 0xca , 0x7b , 0xd9 , 0xe9 , 0x53 , 0x2a , 0xeb , 0xd2 , 0xd8 , 0xcd , 0xa3 , 0x10 , 0x25 ,
0x78 , 0x5a , 0xb5 , 0x23 , 0x06 , 0x93 , 0xb7 , 0x84 , 0xd2 , 0xbd , 0x96 , 0x75 , 0xa5 , 0x5e , 0xcf ,
0x4e , 0xe9 , 0x50 , 0xa1 , 0xe6 , 0x9d , 0xb1 , 0xe3 , 0x85 , 0x66 , 0x28 , 0x4e , 0x43 , 0xdc , 0x6e ,
0xbb , 0x33 , 0x9e , 0xf3 , 0x0d , 0x00 , 0xc1 , 0xcf , 0x67 , 0x34 , 0x06 , 0x7c , 0x71 , 0xe3 , 0x63 ,
0xb7 , 0xb7 , 0xdf , 0x92 , 0xc4 , 0xc2 , 0x25 , 0x5c , 0xff , 0xc3 , 0x6e , 0xfc , 0xaa , 0x1e , 0x2a ,
0x48 , 0x11 , 0x1c , 0x36 , 0x68 , 0x78 , 0x86 , 0x79 , 0x30 , 0xc3 , 0xd6 , 0xde , 0xbc , 0x3a , 0x2a ,
0x6d , 0x1e , 0x46 , 0xdd , 0xe0 , 0x80 , 0x1e , 0x44 , 0x3b , 0x6f , 0xaf , 0x31 , 0xda , 0xa2 , 0xbd ,
0x77 , 0x06 , 0x56 , 0xc0 , 0xb7 , 0x92 , 0x4b , 0x37 , 0xc0 , 0xfc , 0xc2 , 0xd5 , 0xfb , 0xa8 , 0xda ,
0xf5 , 0x57 , 0xa8 , 0x18 , 0xc0 , 0xdf , 0xe7 , 0xaa , 0x2a , 0xe0 , 0x7c , 0x6f , 0x77 , 0xb1 , 0x26 ,
0xba , 0xf9 , 0x2e , 0x1d , 0x16 , 0xcb , 0xb8 , 0xa2 , 0x44 , 0xd5 , 0x2f , 0x1a , 0x79 , 0x74 , 0x87 ,
0x4b , 0x00 , 0xc9 , 0x4a , 0x3a , 0x65 , 0x8f , 0xe6 , 0x5d , 0xe5 , 0x0a , 0x77 , 0xd8 , 0x1a , 0x14 ,
0x41 , 0x75 , 0xb1 , 0xe2 , 0x50 , 0x2c , 0x93 , 0x38 , 0x2b , 0x6d , 0xf3 , 0xf6 , 0xdb , 0x1f , 0xcd ,
0xff , 0x14 , 0x70 , 0xe7 , 0x16 , 0xe8 , 0x3d , 0xf0 , 0xe3 , 0xbc , 0x5e , 0xb6 , 0x3f , 0xcc , 0x81 ,
0x24 , 0x67 , 0xf3 , 0x97 , 0x3b , 0xfe , 0x3a , 0x96 , 0x85 , 0xdf , 0xe4 , 0x6e , 0x3c , 0x85 , 0x05 ,
0x0e , 0xa3 , 0x2b , 0x07 , 0xc8 , 0xbf , 0xe5 , 0x13 , 0x82 , 0x62 , 0x08 , 0x61 , 0x69 , 0x4b , 0x47 ,
0x62 , 0x73 , 0x44 , 0x64 , 0x8e , 0xe2 , 0x91 , 0xa6 , 0x9a , 0xb7 , 0xe9 , 0x04 , 0xb6 , 0x54 , 0x0c ,
0xc5 , 0xa9 , 0x47 , 0xa6 , 0xc9 , 0x08 , 0xfe , 0x4e , 0xa6 , 0xcc , 0x8a , 0x5b , 0x90 , 0x6f , 0x2b ,
0x3f , 0xb6 , 0x0a , 0x96 , 0xc0 , 0x78 , 0x58 , 0x3c , 0x76 , 0x6d , 0x94 , 0x1a , 0xe4 , 0x4e , 0xb8 ,
0x38 , 0xbb , 0xf5 , 0xeb , 0x29 , 0xd8 , 0xb0 , 0xf3 , 0x15 , 0x1e , 0x99 , 0x96 , 0x3c , 0x5d , 0x63 ,
0xd5 , 0xb1 , 0xad , 0x52 , 0xb8 , 0x55 , 0x70 , 0x75 , 0x3e , 0x1a , 0xd5 , 0xda , 0xf6 , 0x7a , 0x48 ,
0x7d , 0x44 , 0x41 , 0xf9 , 0x11 , 0xce , 0xd7 , 0xca , 0xa5 , 0x3d , 0x7a , 0x79 , 0x7e , 0x7d , 0x25 ,
0x1b , 0x77 , 0xbc , 0xf7 , 0xc7 , 0x0f , 0x84 , 0x95 , 0x10 , 0x92 , 0x67 , 0x15 , 0x11 , 0x5a , 0x5e ,
0x41 , 0x66 , 0x0f , 0x38 , 0x03 , 0xb2 , 0xf1 , 0x5d , 0xf8 , 0xab , 0xc0 , 0x02 , 0x76 , 0x84 , 0x28 ,
0xf4 , 0x9d , 0x56 , 0x46 , 0x60 , 0x20 , 0xdb , 0x68 , 0xa7 , 0xbb , 0xee , 0xac , 0x15 , 0x01 , 0x2f ,
0x20 , 0x09 , 0xdb , 0xc0 , 0x16 , 0xa1 , 0x89 , 0xf9 , 0x94 , 0x59 , 0x00 , 0xc1 , 0x76 , 0xbf , 0xc1 ,
0x4d , 0x5d , 0x2d , 0xa9 , 0x85 , 0x2c , 0xd6 , 0xd3 , 0x14 , 0xcc , 0x02 , 0xc3 , 0xc2 , 0xfa , 0x6b ,
0xb7 , 0xa6 , 0xef , 0xdd , 0x12 , 0x26 , 0xa4 , 0x63 , 0xe3 , 0x62 , 0xbd , 0x56 , 0x8a , 0x52 , 0x2b ,
0xb9 , 0xdf , 0x09 , 0xbc , 0x0e , 0x97 , 0xa9 , 0xb0 , 0x82 , 0x46 , 0x08 , 0xd5 , 0x1a , 0x8e , 0x1b ,
0xa7 , 0x90 , 0x98 , 0xb9 , 0xbb , 0x3c , 0x17 , 0x9a , 0xf2 , 0x82 , 0xba , 0x64 , 0x0a , 0x7f , 0xca ,
0x5a , 0x8c , 0x7c , 0xd3 , 0x79 , 0x09 , 0x5b , 0x26 , 0xbb , 0xbd , 0x25 , 0xdf , 0x3d , 0x6f , 0x9a ,
0x8f , 0xee , 0x21 , 0x66 , 0xb0 , 0x8d , 0x84 , 0x4c , 0x91 , 0x45 , 0xd4 , 0x77 , 0x4f , 0xb3 , 0x8c ,
0xbc , 0xa8 , 0x99 , 0xaa , 0x19 , 0x53 , 0x7c , 0x02 , 0x87 , 0xbb , 0x0b , 0x7c , 0x1a , 0x2d , 0xdf ,
0x48 , 0x44 , 0x06 , 0xd6 , 0x7d , 0x0c , 0x2d , 0x35 , 0x76 , 0xae , 0xc4 , 0x5f , 0x71 , 0x85 , 0x97 ,
0xc4 , 0x3d , 0xef , 0x52 , 0xbe , 0x00 , 0xe4 , 0xcd , 0x49 , 0xd1 , 0xd1 , 0x1c , 0x3c , 0xd0 , 0x1c ,
0x42 , 0xaf , 0xd4 , 0xbd , 0x58 , 0x34 , 0x07 , 0x32 , 0xee , 0xb9 , 0xb5 , 0xea , 0xff , 0xd7 , 0x8c ,
0x0d , 0x2e , 0x2f , 0xaf , 0x87 , 0xbb , 0xe6 , 0x52 , 0x71 , 0x22 , 0xf5 , 0x25 , 0x17 , 0xa1 , 0x82 ,
0x04 , 0xc2 , 0x4a , 0xbd , 0x57 , 0xc6 , 0xab , 0xc8 , 0x35 , 0x0c , 0x3c , 0xd9 , 0xc2 , 0x43 , 0xdb ,
0x27 , 0x92 , 0xcf , 0xb8 , 0x25 , 0x60 , 0xfa , 0x21 , 0x3b , 0x04 , 0x52 , 0xc8 , 0x96 , 0xba , 0x74 ,
0xe3 , 0x67 , 0x3e , 0x8e , 0x8d , 0x61 , 0x90 , 0x92 , 0x59 , 0xb6 , 0x1a , 0x1c , 0x5e , 0x21 , 0xc1 ,
0x65 , 0xe5 , 0xa6 , 0x34 , 0x05 , 0x6f , 0xc5 , 0x60 , 0xb1 , 0x83 , 0xc1 , 0xd5 , 0xd5 , 0xed , 0xd9 ,
0xc7 , 0x11 , 0x7b , 0x49 , 0x7a , 0xf9 , 0xf9 , 0x84 , 0x47 , 0x9b , 0xe2 , 0xa5 , 0x82 , 0xe0 , 0xc2 ,
0x88 , 0xd0 , 0xb2 , 0x58 , 0x88 , 0x7f , 0x45 , 0x09 , 0x67 , 0x74 , 0x61 , 0xbf , 0xe6 , 0x40 , 0xe2 ,
0x9d , 0xc2 , 0x47 , 0x05 , 0x89 , 0xed , 0xcb , 0xbb , 0xb7 , 0x27 , 0xe7 , 0xdc , 0x7a , 0xfd , 0xbf ,
0xa8 , 0xd0 , 0xaa , 0x10 , 0x39 , 0x3c , 0x20 , 0xf0 , 0xd3 , 0x6e , 0xb1 , 0x72 , 0xf8 , 0xe6 , 0x0f ,
0xef , 0x37 , 0xe5 , 0x09 , 0x33 , 0x5a , 0x83 , 0x43 , 0x80 , 0x4f , 0x65 , 0x2f , 0x7c , 0x8c , 0x6a ,
0xa0 , 0x82 , 0x0c , 0xd4 , 0xd4 , 0xfa , 0x81 , 0x60 , 0x3d , 0xdf , 0x06 , 0xf1 , 0x5f , 0x08 , 0x0d ,
0x6d , 0x43 , 0xf2 , 0xe3 , 0x11 , 0x7d , 0x80 , 0x32 , 0xc5 , 0xfb , 0xc5 , 0xd9 , 0x27 , 0xec , 0xc6 ,
0x4e , 0x65 , 0x27 , 0x76 , 0x87 , 0xa6 , 0xee , 0xee , 0xd7 , 0x8b , 0xd1 , 0xa0 , 0x5c , 0xb0 , 0x42 ,
0x13 , 0x0e , 0x95 , 0x4a , 0xf2 , 0x06 , 0xc6 , 0x43 , 0x33 , 0xf4 , 0xc7 , 0xf8 , 0xe7 , 0x1f , 0xdd ,
0xe4 , 0x46 , 0x4a , 0x70 , 0x39 , 0x6c , 0xd0 , 0xed , 0xca , 0xbe , 0x60 , 0x3b , 0xd1 , 0x7b , 0x57 ,
0x48 , 0xe5 , 0x3a , 0x79 , 0xc1 , 0x69 , 0x33 , 0x53 , 0x1b , 0x80 , 0xb8 , 0x91 , 0x7d , 0xb4 , 0xf6 ,
0x17 , 0x1a , 0x1d , 0x5a , 0x32 , 0xd6 , 0xcc , 0x71 , 0x29 , 0x3f , 0x28 , 0xbb , 0xf3 , 0x5e , 0x71 ,
0xb8 , 0x43 , 0xaf , 0xf8 , 0xb9 , 0x64 , 0xef , 0xc4 , 0xa5 , 0x6c , 0x08 , 0x53 , 0xc7 , 0x00 , 0x10 ,
0x39 , 0x4f , 0xdd , 0xe4 , 0xb6 , 0x19 , 0x27 , 0xfb , 0xb8 , 0xf5 , 0x32 , 0x73 , 0xe5 , 0xcb , 0x32
} ;
/*
= = = = = = = = = = = = = = = = = = = =
COM_BlockSequenceCRCByte
For proxy protecting
= = = = = = = = = = = = = = = = = = = =
*/
qbyte Q2COM_BlockSequenceCRCByte ( qbyte * base , int length , int sequence )
{
int n ;
qbyte * p ;
int x ;
qbyte chkb [ 60 + 4 ] ;
unsigned short crc ;
if ( sequence < 0 )
Sys_Error ( " sequence < 0, this shouldn't happen \n " ) ;
p = q2chktbl + ( sequence % ( sizeof ( q2chktbl ) - 4 ) ) ;
if ( length > 60 )
length = 60 ;
memcpy ( chkb , base , length ) ;
chkb [ length ] = p [ 0 ] ;
chkb [ length + 1 ] = p [ 1 ] ;
chkb [ length + 2 ] = p [ 2 ] ;
chkb [ length + 3 ] = p [ 3 ] ;
length + = 4 ;
2005-09-08 22:52:46 +00:00
crc = QCRC_Block ( chkb , length ) ;
2004-08-21 01:25:48 +00:00
for ( x = 0 , n = 0 ; n < length ; n + + )
x + = chkb [ n ] ;
crc = ( crc ^ x ) & 0xff ;
return crc ;
}
# endif
2006-03-06 21:29:24 +00:00
# ifdef _WIN32
2006-03-06 21:33:29 +00:00
// don't use these functions in MSVC8
# if (_MSC_VER < 1400)
2006-03-06 01:41:09 +00:00
int VARGS linuxlike_snprintf ( char * buffer , int size , const char * format , . . . )
{
# undef _vsnprintf
int ret ;
va_list argptr ;
if ( size < = 0 )
return 0 ;
size - - ;
va_start ( argptr , format ) ;
ret = _vsnprintf ( buffer , size , format , argptr ) ;
va_end ( argptr ) ;
buffer [ size ] = ' \0 ' ;
return ret ;
}
int VARGS linuxlike_vsnprintf ( char * buffer , int size , const char * format , va_list argptr )
{
# undef _vsnprintf
int ret ;
if ( size < = 0 )
return 0 ;
size - - ;
ret = _vsnprintf ( buffer , size , format , argptr ) ;
buffer [ size ] = ' \0 ' ;
return ret ;
}
2006-05-18 02:54:22 +00:00
# else
int VARGS linuxlike_snprintf_vc8 ( char * buffer , int size , const char * format , . . . )
{
int ret ;
va_list argptr ;
va_start ( argptr , format ) ;
ret = vsnprintf_s ( buffer , size , _TRUNCATE , format , argptr ) ;
va_end ( argptr ) ;
return ret ;
}
2006-03-06 21:29:24 +00:00
# endif
2006-03-06 21:33:29 +00:00
# endif
2009-04-08 08:12:29 +00:00
// libSDL.a and libSDLmain.a mingw32 libs use this function for some reason, just here to shut gcc up
2014-02-07 08:38:40 +00:00
/*#ifdef _MINGW_VFPRINTF
2009-04-08 08:12:29 +00:00
int __mingw_vfprintf ( FILE * __stream , const char * __format , __VALIST __local_argv )
{
return vfprintf ( __stream , __format , __local_argv ) ;
}
2014-02-07 08:38:40 +00:00
# endif* /
2011-03-30 15:17:55 +00:00
int version_number ( void )
{
int base = FTE_VER_MAJOR * 10000 + FTE_VER_MINOR * 100 ;
# ifdef OFFICIAL_RELEASE
base - = 1 ;
# endif
return base ;
}
char * version_string ( void )
{
static char s [ 128 ] ;
static qboolean done ;
if ( ! done )
{
# ifdef OFFICIAL_RELEASE
Q_snprintfz ( s , sizeof ( s ) , " %s v%i.%02i " , DISTRIBUTION , FTE_VER_MAJOR , FTE_VER_MINOR ) ;
# else
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
# if defined(SVNREVISION)
if ( strcmp ( STRINGIFY ( SVNREVISION ) , " - " ) )
Q_snprintfz ( s , sizeof ( s ) , " %s SVN %s " , DISTRIBUTION , STRINGIFY ( SVNREVISION ) ) ;
else
# endif
2011-03-30 15:17:55 +00:00
Q_snprintfz ( s , sizeof ( s ) , " %s build %s " , DISTRIBUTION , __DATE__ ) ;
# endif
done = true ;
}
return s ;
}
2011-12-24 04:05:28 +00:00
//C90
void COM_TimeOfDay ( date_t * date )
{
struct tm * newtime ;
time_t long_time ;
time ( & long_time ) ;
newtime = localtime ( & long_time ) ;
date - > day = newtime - > tm_mday ;
date - > mon = newtime - > tm_mon ;
date - > year = newtime - > tm_year + 1900 ;
date - > hour = newtime - > tm_hour ;
date - > min = newtime - > tm_min ;
date - > sec = newtime - > tm_sec ;
strftime ( date - > str , 128 ,
2012-09-30 05:52:03 +00:00
" %a %b %d, %H:%M:%S %Y " , newtime ) ;
2011-12-24 04:05:28 +00:00
}