09 Jun 2008
This commit is contained in:
parent
3242e34c18
commit
b733d464e7
|
@ -131,91 +131,115 @@ void PF_ReadEntity (void){ VM_RETURN_EDICT( PRVM_PROG_TO_EDICT( MSG_ReadShort( c
|
|||
//NOTE: intervals between various "interfaces" was leave for future expansions
|
||||
prvm_builtin_t vm_cl_builtins[] =
|
||||
{
|
||||
NULL, // #0
|
||||
NULL, // #0 (leave blank as default, but can include easter egg )
|
||||
|
||||
// network messaging
|
||||
PF_BeginRead, // #1 void MsgBegin( void )
|
||||
NULL, // #2
|
||||
PF_ReadChar, // #3 float ReadChar (float f)
|
||||
PF_ReadShort, // #4 float ReadShort (float f)
|
||||
PF_ReadLong, // #5 float ReadLong (float f)
|
||||
PF_ReadFloat, // #6 float ReadFloat (float f)
|
||||
PF_ReadAngle, // #7 float ReadAngle (float f)
|
||||
PF_ReadCoord, // #8 float ReadCoord (float f)
|
||||
PF_ReadString, // #9 string ReadString (string s)
|
||||
PF_ReadEntity, // #10 entity ReadEntity (entity s)
|
||||
PF_EndRead, // #11 void MsgEnd( void )
|
||||
// system events
|
||||
VM_ConPrintf, // #1 void Con_Printf( ... )
|
||||
VM_ConDPrintf, // #2 void Con_DPrintf( float level, ... )
|
||||
VM_HostError, // #3 void Com_Error( ... )
|
||||
VM_SysExit, // #4 void Sys_Exit( void )
|
||||
VM_CmdArgv, // #5 string Cmd_Argv( float arg )
|
||||
VM_CmdArgc, // #6 float Cmd_Argc( void )
|
||||
NULL, // #7 -- reserved --
|
||||
NULL, // #8 -- reserved --
|
||||
NULL, // #9 -- reserved --
|
||||
NULL, // #10 -- reserved --
|
||||
|
||||
// common tools
|
||||
VM_ComTrace, // #11 void Com_Trace( float enable )
|
||||
VM_ComFileExists, // #12 float Com_FileExists( string filename )
|
||||
VM_ComFileSize, // #13 float Com_FileSize( string filename )
|
||||
VM_ComFileTime, // #14 float Com_FileTime( string filename )
|
||||
VM_ComLoadScript, // #15 float Com_LoadScript( string filename )
|
||||
VM_ComResetScript, // #16 void Com_ResetScript( void )
|
||||
VM_ComReadToken, // #17 string Com_ReadToken( float newline )
|
||||
VM_ComFilterToken, // #18 float Com_Filter( string mask, string s, float casecmp )
|
||||
VM_ComSearchFiles, // #19 float Com_Search( string mask, float casecmp )
|
||||
VM_ComSearchNames, // #20 string Com_SearchFilename( float num )
|
||||
VM_RandomLong, // #21 float RandomLong( float min, float max )
|
||||
VM_RandomFloat, // #22 float RandomFloat( float min, float max )
|
||||
VM_RandomVector, // #23 vector RandomVector( vector min, vector max )
|
||||
VM_CvarRegister, // #24 void Cvar_Register( string name, string value, float flags )
|
||||
VM_CvarSetValue, // #25 void Cvar_SetValue( string name, float value )
|
||||
VM_CvarGetValue, // #26 float Cvar_GetValue( string name )
|
||||
VM_ComVA, // #27 string va( ... )
|
||||
VM_ComStrlen, // #28 float strlen( string text )
|
||||
VM_TimeStamp, // #29 string Com_TimeStamp( float format )
|
||||
VM_LocalCmd, // #30 void LocalCmd( ... )
|
||||
NULL, // #31 -- reserved --
|
||||
NULL, // #32 -- reserved --
|
||||
NULL, // #33 -- reserved --
|
||||
NULL, // #34 -- reserved --
|
||||
NULL, // #35 -- reserved --
|
||||
NULL, // #36 -- reserved --
|
||||
NULL, // #37 -- reserved --
|
||||
NULL, // #38 -- reserved --
|
||||
NULL, // #39 -- reserved --
|
||||
NULL, // #40 -- reserved --
|
||||
|
||||
// quakec intrinsics ( compiler will be lookup this functions, don't remove or rename )
|
||||
VM_SpawnEdict, // #41 entity spawn( void )
|
||||
VM_RemoveEdict, // #42 void remove( entity ent )
|
||||
VM_NextEdict, // #43 entity nextent( entity ent )
|
||||
VM_CopyEdict, // #44 void copyentity( entity src, entity dst )
|
||||
NULL, // #45 -- reserved --
|
||||
NULL, // #46 -- reserved --
|
||||
NULL, // #47 -- reserved --
|
||||
NULL, // #48 -- reserved --
|
||||
NULL, // #49 -- reserved --
|
||||
NULL, // #50 -- reserved --
|
||||
|
||||
// filesystem
|
||||
VM_FS_Open, // #51 float fopen( string filename, float mode )
|
||||
VM_FS_Close, // #52 void fclose( float handle )
|
||||
VM_FS_Gets, // #53 string fgets( float handle )
|
||||
VM_FS_Gete, // #54 entity fgete( float handle )
|
||||
VM_FS_Puts, // #55 void fputs( float handle, string s )
|
||||
VM_FS_Pute, // #56 void fpute( float handle, entity e )
|
||||
NULL, // #57 -- reserved --
|
||||
NULL, // #58 -- reserved --
|
||||
NULL, // #59 -- reserved --
|
||||
NULL, // #60 -- reserved --
|
||||
|
||||
// mathlib
|
||||
VM_min, // #12 float min(float a, float b )
|
||||
VM_max, // #13 float max(float a, float b )
|
||||
VM_bound, // #14 float bound(float min, float val, float max)
|
||||
VM_pow, // #15 float pow(float x, float y)
|
||||
VM_sin, // #16 float sin(float f)
|
||||
VM_cos, // #17 float cos(float f)
|
||||
VM_sqrt, // #18 float sqrt(float f)
|
||||
VM_rint, // #19 float rint (float v)
|
||||
VM_floor, // #20 float floor(float v)
|
||||
VM_ceil, // #21 float ceil (float v)
|
||||
VM_fabs, // #22 float fabs (float f)
|
||||
VM_random_long, // #23 float random_long( void )
|
||||
VM_random_float, // #24 float random_float( void )
|
||||
NULL, // #25
|
||||
NULL, // #26
|
||||
NULL, // #27
|
||||
NULL, // #28
|
||||
NULL, // #29
|
||||
NULL, // #30
|
||||
VM_min, // #61 float min(float a, float b )
|
||||
VM_max, // #62 float max(float a, float b )
|
||||
VM_bound, // #63 float bound(float min, float val, float max)
|
||||
VM_pow, // #64 float pow(float x, float y)
|
||||
VM_sin, // #65 float sin(float f)
|
||||
VM_cos, // #66 float cos(float f)
|
||||
VM_tan, // #67 float tan(float f)
|
||||
VM_asin, // #68 float asin(float f)
|
||||
VM_acos, // #69 float acos(float f)
|
||||
VM_atan, // #70 float atan(float f)
|
||||
VM_sqrt, // #71 float sqrt(float f)
|
||||
VM_rint, // #72 float rint (float v)
|
||||
VM_floor, // #73 float floor(float v)
|
||||
VM_ceil, // #74 float ceil (float v)
|
||||
VM_fabs, // #75 float fabs (float f)
|
||||
VM_mod, // #76 float fmod( float val, float m )
|
||||
NULL, // #77 -- reserved --
|
||||
NULL, // #78 -- reserved --
|
||||
VM_VectorNormalize, // #79 vector VectorNormalize( vector v )
|
||||
VM_VectorLength, // #80 float VectorLength( vector v )
|
||||
e10, e10, // #81 - #100 are reserved for future expansions
|
||||
|
||||
// vector mathlib
|
||||
VM_normalize, // #31 vector normalize(vector v)
|
||||
VM_veclength, // #32 float veclength(vector v)
|
||||
VM_vectoyaw, // #33 float vectoyaw(vector v)
|
||||
VM_vectoangles, // #34 vector vectoangles(vector v)
|
||||
VM_randomvec, // #35 vector randomvec( void )
|
||||
VM_vectorvectors, // #36 void vectorvectors(vector dir)
|
||||
VM_makevectors, // #37 void makevectors(vector dir)
|
||||
VM_makevectors2, // #38 void makevectors2(vector dir)
|
||||
NULL, // #39
|
||||
NULL, // #40
|
||||
// network messaging
|
||||
PF_BeginRead, // #101 void MsgBegin( void )
|
||||
NULL, // #102
|
||||
PF_ReadChar, // #103 float ReadChar (float f)
|
||||
PF_ReadShort, // #104 float ReadShort (float f)
|
||||
PF_ReadLong, // #105 float ReadLong (float f)
|
||||
PF_ReadFloat, // #106 float ReadFloat (float f)
|
||||
PF_ReadAngle, // #107 float ReadAngle (float f)
|
||||
PF_ReadCoord, // #108 float ReadCoord (float f)
|
||||
PF_ReadString, // #109 string ReadString (string s)
|
||||
PF_ReadEntity, // #110 entity ReadEntity (entity s)
|
||||
PF_EndRead, // #111 void MsgEnd( void )
|
||||
|
||||
// stdlib functions
|
||||
VM_atof, // #41 float atof(string s)
|
||||
VM_ftoa, // #42 string ftoa(float s)
|
||||
VM_vtoa, // #43 string vtoa(vector v)
|
||||
VM_atov, // #44 vector atov(string s)
|
||||
VM_ConPrintf, // #45 void Msg( ... )
|
||||
VM_wprint, // #46 void MsgWarn( ... )
|
||||
VM_objerror, // #47 void Error( ... )
|
||||
VM_bprint, // #48 void bprint(string s)
|
||||
NULL, // #49
|
||||
NULL, // #50
|
||||
VM_cvar, // #51 float cvar(string s)
|
||||
VM_cvar_set, // #52 void cvar_set(string var, string val)
|
||||
VM_allocstring, // #53 string AllocString(string s)
|
||||
VM_freestring, // #54 void FreeString(string s)
|
||||
VM_strlen, // #55 float strlen(string s)
|
||||
VM_strcat, // #56 string strcat(string s1, string s2)
|
||||
VM_argv, // #57 string argv( float parm )
|
||||
NULL, // #58
|
||||
NULL, // #59
|
||||
NULL, // #60
|
||||
|
||||
// internal debugger
|
||||
VM_break, // #61 void break( void )
|
||||
VM_crash, // #62 void crash( void )
|
||||
VM_coredump, // #63 void coredump( void )
|
||||
VM_stackdump, // #64 void stackdump( void )
|
||||
VM_traceon, // #65 void trace_on( void )
|
||||
VM_traceoff, // #66 void trace_off( void )
|
||||
VM_eprint, // #67 void dump_edict(entity e)
|
||||
VM_nextent, // #68 entity nextent(entity e)
|
||||
NULL, // #69
|
||||
NULL, // #70
|
||||
// clientfuncs_t
|
||||
PF_ScreenAdjustSize, // #71 void SCR_AdjustSize( void )
|
||||
PF_FillRect, // #72 void SCR_FillRect( float x, float y, float w, float h, vector col )
|
||||
VM_create, // #73
|
||||
PF_ScreenAdjustSize, // #112 void SCR_AdjustSize( void )
|
||||
PF_FillRect, // #113 void SCR_FillRect( float x, float y, float w, float h, vector col )
|
||||
};
|
||||
|
||||
const int vm_cl_numbuiltins = sizeof(vm_cl_builtins) / sizeof(prvm_builtin_t); //num of builtins
|
||||
|
|
710
engine/common.c
710
engine/common.c
|
@ -5,6 +5,9 @@
|
|||
|
||||
#include "engine.h"
|
||||
#include "basefiles.h"
|
||||
#include "mathlib.h"
|
||||
|
||||
static search_t *vm_search;
|
||||
|
||||
/*
|
||||
=======================================================================
|
||||
|
@ -27,6 +30,12 @@ bool VM_ValidateArgs( const char *builtin, int num_argc )
|
|||
return true;
|
||||
}
|
||||
|
||||
void VM_ValidateString( const char *s )
|
||||
{
|
||||
if( s[0] <= ' ' ) PRVM_ERROR( "%s: bad string", PRVM_NAME );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_VarArgs
|
||||
|
@ -56,12 +65,16 @@ const char *VM_VarArgs( int start_arg )
|
|||
s = PRVM_G_STRING((OFS_PARM0 + start_arg * 3));
|
||||
out = vm_string;
|
||||
outend = out + MAX_STRING_CHARS - 1;
|
||||
memset( vm_string, 0, MAX_STRING_CHARS - 1 );
|
||||
|
||||
while( out < outend && *s )
|
||||
{
|
||||
*out++ = *s++; // copy symbols
|
||||
if( arg > prog->argc ) break; // simple boundschecker
|
||||
if( *s != '%' ) continue; // wait for percents
|
||||
if( *s != '%' )
|
||||
{
|
||||
*out++ = *s++; // copy symbols
|
||||
continue; // wait for percents
|
||||
}
|
||||
|
||||
switch((int)s[1])
|
||||
{
|
||||
|
@ -70,9 +83,7 @@ const char *VM_VarArgs( int start_arg )
|
|||
case 's': com.snprintf( vm_arg, MAX_STRING, "%s", PRVM_G_STRING(OFS_PARM0+arg*3)); break;
|
||||
case 'f': com.snprintf( vm_arg, MAX_STRING, "%f", PRVM_G_FLOAT(OFS_PARM0+arg*3)); break;
|
||||
case 'g': com.snprintf( vm_arg, MAX_STRING, "%g", PRVM_G_FLOAT(OFS_PARM0+arg*3)); break;
|
||||
case 'e':
|
||||
com.snprintf( vm_arg, MAX_STRING, "%i", PRVM_G_EDICTNUM(OFS_PARM0+arg*3));
|
||||
break;
|
||||
case 'e': com.snprintf( vm_arg, MAX_STRING, "%i", PRVM_G_EDICTNUM(OFS_PARM0+arg*3)); break;
|
||||
case 'p': // function ptr
|
||||
func = prog->functions + PRVM_G_INT(OFS_PARM0+arg*3);
|
||||
if(!func->s_name) com.strncpy( vm_arg, "(null)", MAX_STRING ); // MSVCRT style
|
||||
|
@ -220,6 +231,7 @@ void VM_ComFileExists( void )
|
|||
if(!VM_ValidateArgs( "Com_FileExists", 1 ))
|
||||
return;
|
||||
|
||||
VM_ValidateString(PRVM_G_STRING(OFS_PARM0));
|
||||
PRVM_G_FLOAT(OFS_RETURN) = FS_FileExists(PRVM_G_STRING(OFS_PARM0)) ? 1.0f : 0.0f;
|
||||
}
|
||||
|
||||
|
@ -235,6 +247,7 @@ void VM_ComFileSize( void )
|
|||
if(!VM_ValidateArgs( "Com_FileSize", 1 ))
|
||||
return;
|
||||
|
||||
VM_ValidateString(PRVM_G_STRING(OFS_PARM0));
|
||||
PRVM_G_FLOAT(OFS_RETURN) = (float)FS_FileSize(PRVM_G_STRING(OFS_PARM0));
|
||||
}
|
||||
|
||||
|
@ -250,97 +263,509 @@ void VM_ComFileTime( void )
|
|||
if(!VM_ValidateArgs( "Com_FileTime", 1 ))
|
||||
return;
|
||||
|
||||
VM_ValidateString(PRVM_G_STRING(OFS_PARM0));
|
||||
PRVM_G_FLOAT(OFS_RETURN) = (float)FS_FileTime(PRVM_G_STRING(OFS_PARM0));
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_ComLoadScript
|
||||
|
||||
float Com_LoadScript( string filename )
|
||||
=========
|
||||
*/
|
||||
void VM_ComLoadScript( void )
|
||||
{
|
||||
static byte *script;
|
||||
static size_t length;
|
||||
|
||||
if(!VM_ValidateArgs( "Com_LoadScript", 1 ))
|
||||
return;
|
||||
|
||||
VM_ValidateString(PRVM_G_STRING(OFS_PARM0));
|
||||
|
||||
// place script into memory
|
||||
if( script && length ) Mem_Free( script );
|
||||
script = FS_LoadFile( PRVM_G_STRING(OFS_PARM0), &length );
|
||||
|
||||
PRVM_G_FLOAT(OFS_RETURN) = (float)Com_LoadScript( "VM script", script, length );
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_ComResetScript
|
||||
|
||||
void Com_ResetScript( void )
|
||||
=========
|
||||
*/
|
||||
void VM_ComResetScript( void )
|
||||
{
|
||||
if(!VM_ValidateArgs( "Com_ResetScript", 0 ))
|
||||
return;
|
||||
|
||||
Com_ResetScript();
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_ComReadToken
|
||||
|
||||
string Com_ReadToken( float newline )
|
||||
=========
|
||||
*/
|
||||
void VM_ComReadToken( void )
|
||||
{
|
||||
if(!VM_ValidateArgs( "Com_ReadToken", 1 ))
|
||||
return;
|
||||
|
||||
// using slow, but safe parsing method
|
||||
if( PRVM_G_FLOAT(OFS_PARM0) )
|
||||
{
|
||||
Com_GetToken( true ); // newline token is always safe
|
||||
PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString( com_token );
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Com_TryToken()) // token available
|
||||
PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString( com_token );
|
||||
else PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString( NULL );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_ComFilterToken
|
||||
|
||||
float Com_Filter( string mask, string s, float casecmp )
|
||||
=========
|
||||
*/
|
||||
void VM_ComFilterToken( void )
|
||||
{
|
||||
const char *mask, *name;
|
||||
bool casecmp;
|
||||
|
||||
if(!VM_ValidateArgs( "Com_Filter", 3 ))
|
||||
return;
|
||||
|
||||
VM_ValidateString(PRVM_G_STRING(OFS_PARM0));
|
||||
VM_ValidateString(PRVM_G_STRING(OFS_PARM1));
|
||||
|
||||
mask = PRVM_G_STRING(OFS_PARM0);
|
||||
name = PRVM_G_STRING(OFS_PARM1);
|
||||
casecmp = PRVM_G_FLOAT(OFS_PARM2) ? true : false;
|
||||
|
||||
PRVM_G_FLOAT(OFS_RETURN) = (float)Com_Filter( (char *)mask, (char *)name, casecmp );
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_ComSearchFiles
|
||||
|
||||
float Com_Search( string mask, float casecmp )
|
||||
=========
|
||||
*/
|
||||
void VM_ComSearchFiles( void )
|
||||
{
|
||||
const char *mask;
|
||||
bool casecmp;
|
||||
int numfiles = 0;
|
||||
|
||||
if(!VM_ValidateArgs( "Com_Search", 2 ))
|
||||
return;
|
||||
|
||||
VM_ValidateString(PRVM_G_STRING(OFS_PARM0));
|
||||
|
||||
// release previous search
|
||||
if( vm_search ) Mem_Free( vm_search );
|
||||
|
||||
mask = PRVM_G_STRING(OFS_PARM0);
|
||||
casecmp = PRVM_G_FLOAT(OFS_PARM1) ? true : false;
|
||||
|
||||
vm_search = FS_Search( mask, casecmp );
|
||||
|
||||
if( vm_search ) numfiles = vm_search->numfilenames;
|
||||
PRVM_G_FLOAT(OFS_RETURN) = (float)numfiles;
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_ComSearchNames
|
||||
|
||||
string Com_SearchFilename( float num )
|
||||
=========
|
||||
*/
|
||||
void VM_ComSearchNames( void )
|
||||
{
|
||||
int num;
|
||||
|
||||
if(!VM_ValidateArgs( "Com_SearchFilename", 1 ))
|
||||
return;
|
||||
|
||||
num = PRVM_G_FLOAT(OFS_PARM0);
|
||||
|
||||
if( vm_search && vm_search->numfilenames > num ) // in-range
|
||||
PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString( vm_search->filenames[num] );
|
||||
else PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString( NULL );
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_RandomLong
|
||||
|
||||
float RandomLong( float min, float max )
|
||||
=========
|
||||
*/
|
||||
void VM_RandomLong( void )
|
||||
{
|
||||
if(!VM_ValidateArgs( "RandomLong", 2 ))
|
||||
return;
|
||||
|
||||
PRVM_G_FLOAT(OFS_RETURN) = RANDOM_LONG(PRVM_G_FLOAT(OFS_PARM0), PRVM_G_FLOAT(OFS_PARM1));
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_RandomFloat
|
||||
|
||||
float RandomFloat( float min, float max )
|
||||
=========
|
||||
*/
|
||||
void VM_RandomFloat( void )
|
||||
{
|
||||
if(!VM_ValidateArgs( "RandomFloat", 2 ))
|
||||
return;
|
||||
|
||||
PRVM_G_FLOAT(OFS_RETURN) = RANDOM_FLOAT(PRVM_G_FLOAT(OFS_PARM0), PRVM_G_FLOAT(OFS_PARM1));
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_RandomVector
|
||||
|
||||
float RandomVector( vector min, vector max )
|
||||
=========
|
||||
*/
|
||||
void VM_RandomVector( void )
|
||||
{
|
||||
vec3_t temp;
|
||||
float *min, *max;
|
||||
|
||||
if(!VM_ValidateArgs( "RandomVector", 2 ))
|
||||
return;
|
||||
|
||||
min = PRVM_G_VECTOR(OFS_PARM0);
|
||||
max = PRVM_G_VECTOR(OFS_PARM1);
|
||||
|
||||
temp[0] = RANDOM_FLOAT(min[0], max[0]);
|
||||
temp[1] = RANDOM_FLOAT(min[1], max[1]);
|
||||
temp[2] = RANDOM_FLOAT(min[2], max[2]);
|
||||
|
||||
VectorNormalize2( temp, PRVM_G_VECTOR(OFS_RETURN));
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_CvarRegister
|
||||
|
||||
void Cvar_Register( string name, string value, float flags )
|
||||
=========
|
||||
*/
|
||||
void VM_CvarRegister( void )
|
||||
{
|
||||
const char *name, *value;
|
||||
int flags = 0;
|
||||
|
||||
if(!VM_ValidateArgs( "Cvar_Register", 3 ))
|
||||
return;
|
||||
|
||||
VM_ValidateString(PRVM_G_STRING(OFS_PARM0));
|
||||
VM_ValidateString(PRVM_G_STRING(OFS_PARM1));
|
||||
|
||||
name = PRVM_G_STRING(OFS_PARM0);
|
||||
value = PRVM_G_STRING(OFS_PARM1);
|
||||
|
||||
if((int)PRVM_G_FLOAT(OFS_PARM2) & 1)
|
||||
flags |= CVAR_ARCHIVE;
|
||||
|
||||
if((int)PRVM_G_FLOAT(OFS_PARM2) & 2)
|
||||
flags |= CVAR_CHEAT;
|
||||
|
||||
// register new cvar
|
||||
Cvar_Get( name, value, flags );
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_CvarSetValue
|
||||
|
||||
void Cvar_SetValue( string name, float value )
|
||||
=========
|
||||
*/
|
||||
void VM_CvarSetValue( void )
|
||||
{
|
||||
const char *name;
|
||||
float value;
|
||||
|
||||
if(!VM_ValidateArgs( "Cvar_SetValue", 2 ))
|
||||
return;
|
||||
|
||||
VM_ValidateString(PRVM_G_STRING(OFS_PARM0));
|
||||
name = PRVM_G_STRING(OFS_PARM0);
|
||||
value = PRVM_G_FLOAT(OFS_PARM1);
|
||||
|
||||
// set new value
|
||||
Cvar_SetValue( name, value );
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_CvarGetValue
|
||||
|
||||
float Cvar_GetValue( string name )
|
||||
=========
|
||||
*/
|
||||
void VM_CvarGetValue( void )
|
||||
{
|
||||
const char *name;
|
||||
|
||||
if(!VM_ValidateArgs( "Cvar_GetValue", 1 ))
|
||||
return;
|
||||
|
||||
VM_ValidateString(PRVM_G_STRING(OFS_PARM0));
|
||||
name = PRVM_G_STRING(OFS_PARM0);
|
||||
PRVM_G_FLOAT(OFS_RETURN) = Cvar_VariableValue( name );
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
VM_LocalCmd
|
||||
|
||||
cmd( string, ... )
|
||||
=================
|
||||
*/
|
||||
void VM_LocalCmd( void )
|
||||
{
|
||||
Cbuf_AddText(VM_VarArgs( 0 ));
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_ComVA
|
||||
|
||||
string va( ... )
|
||||
=========
|
||||
*/
|
||||
void VM_ComVA( void )
|
||||
{
|
||||
PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString(VM_VarArgs( 0 ));
|
||||
|
||||
}
|
||||
|
||||
void VM_ComAtof( void )
|
||||
{
|
||||
}
|
||||
|
||||
void VM_ComFtoa( void )
|
||||
{
|
||||
}
|
||||
|
||||
void VM_ComAtov( void )
|
||||
{
|
||||
}
|
||||
|
||||
void VM_ComVtoa( void )
|
||||
{
|
||||
}
|
||||
/*
|
||||
=========
|
||||
VM_ComStrlen
|
||||
|
||||
float strlen( string text )
|
||||
=========
|
||||
*/
|
||||
void VM_ComStrlen( void )
|
||||
{
|
||||
if(!VM_ValidateArgs( "Com_Strlen", 1 )) return;
|
||||
PRVM_G_FLOAT(OFS_RETURN) = com.cstrlen(PRVM_G_STRING(OFS_PARM0));
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_TimeStamp
|
||||
|
||||
string Com_TimeStamp( float format )
|
||||
=========
|
||||
*/
|
||||
void VM_TimeStamp( void )
|
||||
{
|
||||
if(!VM_ValidateArgs( "Com_TimeStamp", 1 ))
|
||||
return;
|
||||
|
||||
PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString(timestamp((int)PRVM_G_FLOAT(OFS_PARM0)));
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_SpawnEdict
|
||||
|
||||
entity spawn( void )
|
||||
=========
|
||||
*/
|
||||
void VM_SpawnEdict( void )
|
||||
{
|
||||
edict_t *ed;
|
||||
|
||||
prog->xfunction->builtinsprofile += 20;
|
||||
ed = PRVM_ED_Alloc();
|
||||
VM_RETURN_EDICT( ed );
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_RemoveEdict
|
||||
|
||||
void remove( entity ent )
|
||||
=========
|
||||
*/
|
||||
void VM_RemoveEdict( void )
|
||||
{
|
||||
edict_t *ed;
|
||||
|
||||
if(!VM_ValidateArgs( "remove", 1 ))
|
||||
return;
|
||||
|
||||
prog->xfunction->builtinsprofile += 20;
|
||||
ed = PRVM_G_EDICT(OFS_PARM0);
|
||||
if( PRVM_NUM_FOR_EDICT(ed) <= prog->reserved_edicts )
|
||||
{
|
||||
if( host.developer >= D_INFO )
|
||||
VM_Warning( "VM_RemoveEdict: tried to remove the null entity or a reserved entity!\n" );
|
||||
}
|
||||
else if( ed->priv.ed->free )
|
||||
{
|
||||
if( host.developer >= D_INFO )
|
||||
VM_Warning( "VM_RemoveEdict: tried to remove an already freed entity!\n" );
|
||||
}
|
||||
else PRVM_ED_Free( ed );
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_NextEdict
|
||||
|
||||
void nextent( entity ent )
|
||||
=========
|
||||
*/
|
||||
void VM_NextEdict( void )
|
||||
{
|
||||
edict_t *ent;
|
||||
int i;
|
||||
|
||||
if(!VM_ValidateArgs( "nextent", 1 ))
|
||||
return;
|
||||
|
||||
i = PRVM_G_EDICTNUM( OFS_PARM0 );
|
||||
while( 1 )
|
||||
{
|
||||
prog->xfunction->builtinsprofile++;
|
||||
i++;
|
||||
if( i == prog->num_edicts )
|
||||
{
|
||||
VM_RETURN_EDICT( prog->edicts );
|
||||
return;
|
||||
}
|
||||
ent = PRVM_EDICT_NUM(i);
|
||||
if(!ent->priv.ed->free)
|
||||
{
|
||||
VM_RETURN_EDICT( ent );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
VM_copyentity
|
||||
|
||||
void copyentity( entity src, entity dst )
|
||||
=================
|
||||
*/
|
||||
void VM_CopyEdict( void )
|
||||
{
|
||||
edict_t *in, *out;
|
||||
|
||||
if(!VM_ValidateArgs( "copyentity", 1 ))
|
||||
return;
|
||||
|
||||
in = PRVM_G_EDICT(OFS_PARM0);
|
||||
out = PRVM_G_EDICT(OFS_PARM1);
|
||||
Mem_Copy( out->progs.vp, in->progs.vp, prog->progs->entityfields * 4 );
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_FindEdict
|
||||
|
||||
entity find( entity start, .string field, string match )
|
||||
=========
|
||||
*/
|
||||
void VM_FindEdict( void )
|
||||
{
|
||||
int e, f;
|
||||
const char *s, *t;
|
||||
edict_t *ed;
|
||||
|
||||
if(!VM_ValidateArgs( "find", 2 ))
|
||||
return;
|
||||
|
||||
e = PRVM_G_EDICTNUM(OFS_PARM0);
|
||||
f = PRVM_G_INT(OFS_PARM1);
|
||||
s = PRVM_G_STRING(OFS_PARM2);
|
||||
if(!s) s = "";
|
||||
|
||||
for( e++; e < prog->num_edicts; e++ )
|
||||
{
|
||||
prog->xfunction->builtinsprofile++;
|
||||
ed = PRVM_EDICT_NUM(e);
|
||||
if( ed->priv.ed->free )continue;
|
||||
t = PRVM_E_STRING( ed, f );
|
||||
if(!t) t = "";
|
||||
if(!com.strcmp( t, s ))
|
||||
{
|
||||
VM_RETURN_EDICT( ed );
|
||||
return;
|
||||
}
|
||||
}
|
||||
VM_RETURN_EDICT( prog->edicts );
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_FindField
|
||||
|
||||
entity findfloat(entity start, .float field, float match)
|
||||
=========
|
||||
*/
|
||||
void VM_FindField( void )
|
||||
{
|
||||
int e, f;
|
||||
float s;
|
||||
edict_t *ed;
|
||||
|
||||
if(!VM_ValidateArgs( "findfloat", 2 ))
|
||||
return;
|
||||
|
||||
e = PRVM_G_EDICTNUM(OFS_PARM0);
|
||||
f = PRVM_G_INT(OFS_PARM1);
|
||||
s = PRVM_G_FLOAT(OFS_PARM2);
|
||||
|
||||
for( e++; e < prog->num_edicts; e++ )
|
||||
{
|
||||
prog->xfunction->builtinsprofile++;
|
||||
ed = PRVM_EDICT_NUM(e);
|
||||
if( ed->priv.ed->free ) continue;
|
||||
if( PRVM_E_FLOAT(ed, f) == s )
|
||||
{
|
||||
VM_RETURN_EDICT( ed );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
VM_RETURN_EDICT( prog->edicts );
|
||||
}
|
||||
|
||||
/*
|
||||
=======================================================================
|
||||
|
||||
VIRTUAL MACHINE FILESYSTEM API
|
||||
=======================================================================
|
||||
*/
|
||||
void VM_FS_Open( void )
|
||||
{
|
||||
}
|
||||
|
@ -365,66 +790,255 @@ void VM_FS_Close( void )
|
|||
{
|
||||
}
|
||||
|
||||
/*
|
||||
=======================================================================
|
||||
|
||||
VIRTUAL MACHINE MATHLIB
|
||||
=======================================================================
|
||||
*/
|
||||
/*
|
||||
=================
|
||||
VM_min
|
||||
|
||||
float min( float a, float b )
|
||||
=================
|
||||
*/
|
||||
void VM_min( void )
|
||||
{
|
||||
if(!VM_ValidateArgs( "min", 2 )) return;
|
||||
PRVM_G_FLOAT(OFS_RETURN) = min(PRVM_G_FLOAT(OFS_PARM0), PRVM_G_FLOAT(OFS_PARM1));
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
VM_max
|
||||
|
||||
float max( float a, float b )
|
||||
=================
|
||||
*/
|
||||
void VM_max( void )
|
||||
{
|
||||
if(!VM_ValidateArgs( "max", 2 )) return;
|
||||
PRVM_G_FLOAT(OFS_RETURN) = max(PRVM_G_FLOAT(OFS_PARM0), PRVM_G_FLOAT(OFS_PARM1));
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
VM_bound
|
||||
|
||||
float bound( float min, float value, float max )
|
||||
=================
|
||||
*/
|
||||
void VM_bound( void )
|
||||
{
|
||||
if(!VM_ValidateArgs( "bound", 3 )) return;
|
||||
PRVM_G_FLOAT(OFS_RETURN) = bound(PRVM_G_FLOAT(OFS_PARM0), PRVM_G_FLOAT(OFS_PARM1), PRVM_G_FLOAT(OFS_PARM2));
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
VM_pow
|
||||
|
||||
float pow( float a, float b )
|
||||
=================
|
||||
*/
|
||||
void VM_pow( void )
|
||||
{
|
||||
if(!VM_ValidateArgs( "pow", 2 )) return;
|
||||
PRVM_G_FLOAT(OFS_RETURN) = pow(PRVM_G_FLOAT(OFS_PARM0), PRVM_G_FLOAT(OFS_PARM1));
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_sin
|
||||
|
||||
float sin(float)
|
||||
float sin( float f )
|
||||
=========
|
||||
*/
|
||||
void VM_sin (void)
|
||||
void VM_sin( void )
|
||||
{
|
||||
VM_SAFEPARMCOUNT(1,VM_sin);
|
||||
if(!VM_ValidateArgs( "sin", 1 )) return;
|
||||
PRVM_G_FLOAT(OFS_RETURN) = sin(PRVM_G_FLOAT(OFS_PARM0));
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_cos
|
||||
float cos(float)
|
||||
|
||||
float cos( float f )
|
||||
=========
|
||||
*/
|
||||
void VM_cos (void)
|
||||
void VM_cos( void )
|
||||
{
|
||||
VM_SAFEPARMCOUNT(1,VM_cos);
|
||||
if(!VM_ValidateArgs( "cos", 1 )) return;
|
||||
PRVM_G_FLOAT(OFS_RETURN) = cos(PRVM_G_FLOAT(OFS_PARM0));
|
||||
}
|
||||
|
||||
void VM_tan (void)
|
||||
/*
|
||||
=========
|
||||
VM_tan
|
||||
|
||||
float tan( float f )
|
||||
=========
|
||||
*/
|
||||
void VM_tan( void )
|
||||
{
|
||||
if(!VM_ValidateArgs( "tan", 1 )) return;
|
||||
PRVM_G_FLOAT(OFS_RETURN) = tan(PRVM_G_FLOAT(OFS_PARM0));
|
||||
}
|
||||
|
||||
void VM_asin (void)
|
||||
/*
|
||||
=========
|
||||
VM_asin
|
||||
|
||||
float asin( float f )
|
||||
=========
|
||||
*/
|
||||
void VM_asin( void )
|
||||
{
|
||||
if(!VM_ValidateArgs( "asin", 1 )) return;
|
||||
PRVM_G_FLOAT(OFS_RETURN) = asin(PRVM_G_FLOAT(OFS_PARM0));
|
||||
}
|
||||
|
||||
void VM_acos (void)
|
||||
/*
|
||||
=========
|
||||
VM_acos
|
||||
|
||||
float acos( float f )
|
||||
=========
|
||||
*/
|
||||
void VM_acos( void )
|
||||
{
|
||||
if(!VM_ValidateArgs( "acos", 1 )) return;
|
||||
PRVM_G_FLOAT(OFS_RETURN) = acos(PRVM_G_FLOAT(OFS_PARM0));
|
||||
}
|
||||
|
||||
void VM_atan (void)
|
||||
/*
|
||||
=========
|
||||
VM_atan
|
||||
|
||||
float atan( float f )
|
||||
=========
|
||||
*/
|
||||
void VM_atan( void )
|
||||
{
|
||||
if(!VM_ValidateArgs( "atan", 1 )) return;
|
||||
PRVM_G_FLOAT(OFS_RETURN) = atan(PRVM_G_FLOAT(OFS_PARM0));
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_sqrt
|
||||
|
||||
float sqrt(float)
|
||||
float sqrt( float f )
|
||||
=========
|
||||
*/
|
||||
void VM_sqrt (void)
|
||||
void VM_sqrt( void )
|
||||
{
|
||||
VM_SAFEPARMCOUNT(1,VM_sqrt);
|
||||
if(!VM_ValidateArgs( "sqrt", 1 )) return;
|
||||
PRVM_G_FLOAT(OFS_RETURN) = sqrt(PRVM_G_FLOAT(OFS_PARM0));
|
||||
}
|
||||
|
||||
void VM_VectorLength( void )
|
||||
/*
|
||||
=========
|
||||
VM_rint
|
||||
|
||||
float rint( float f )
|
||||
=========
|
||||
*/
|
||||
void VM_rint( void )
|
||||
{
|
||||
float f;
|
||||
|
||||
if(!VM_ValidateArgs( "rint", 1 ))
|
||||
return;
|
||||
|
||||
f = PRVM_G_FLOAT(OFS_PARM0);
|
||||
if( f > 0 ) PRVM_G_FLOAT(OFS_RETURN) = floor(f + 0.5);
|
||||
else PRVM_G_FLOAT(OFS_RETURN) = ceil(f - 0.5);
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_floor
|
||||
|
||||
float floor( float f )
|
||||
=========
|
||||
*/
|
||||
void VM_floor( void )
|
||||
{
|
||||
if(!VM_ValidateArgs( "floor", 1 )) return;
|
||||
PRVM_G_FLOAT(OFS_RETURN) = floor(PRVM_G_FLOAT(OFS_PARM0));
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_ceil
|
||||
|
||||
float ceil( float f )
|
||||
=========
|
||||
*/
|
||||
void VM_ceil( void )
|
||||
{
|
||||
if(!VM_ValidateArgs( "ceil", 1 )) return;
|
||||
PRVM_G_FLOAT(OFS_RETURN) = ceil(PRVM_G_FLOAT(OFS_PARM0));
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_fabs
|
||||
|
||||
float fabs( float f )
|
||||
=========
|
||||
*/
|
||||
void VM_fabs( void )
|
||||
{
|
||||
if(!VM_ValidateArgs( "fabs", 1 )) return;
|
||||
PRVM_G_FLOAT(OFS_RETURN) = fabs(PRVM_G_FLOAT(OFS_PARM0));
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_modulo
|
||||
|
||||
float mod( float val, float m )
|
||||
=========
|
||||
*/
|
||||
void VM_mod( void )
|
||||
{
|
||||
int val, m;
|
||||
|
||||
if(!VM_ValidateArgs( "fmod", 2 )) return;
|
||||
|
||||
val = (int)PRVM_G_FLOAT(OFS_PARM0);
|
||||
m = (int)PRVM_G_FLOAT(OFS_PARM1);
|
||||
PRVM_G_FLOAT(OFS_RETURN) = (float)(val % m);
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_VectorNormalize
|
||||
|
||||
vector VectorNormalize( vector v )
|
||||
=========
|
||||
*/
|
||||
void VM_VectorNormalize( void )
|
||||
{
|
||||
if(!VM_ValidateArgs( "normalize", 1 )) return;
|
||||
VectorNormalize2( PRVM_G_VECTOR(OFS_PARM0), PRVM_G_VECTOR(OFS_RETURN));
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_VectorLength
|
||||
|
||||
float VectorLength( vector v )
|
||||
=========
|
||||
*/
|
||||
void VM_VectorLength( void )
|
||||
{
|
||||
if(!VM_ValidateArgs( "veclength", 1 )) return;
|
||||
PRVM_G_FLOAT(OFS_RETURN) = VectorLength(PRVM_G_VECTOR(OFS_PARM0));
|
||||
}
|
||||
|
||||
prvm_builtin_t std_builtins[] =
|
||||
|
@ -452,21 +1066,21 @@ VM_ComLoadScript, // #15 float Com_LoadScript( string filename )
|
|||
VM_ComResetScript, // #16 void Com_ResetScript( void )
|
||||
VM_ComReadToken, // #17 string Com_ReadToken( float newline )
|
||||
VM_ComFilterToken, // #18 float Com_Filter( string mask, string s, float casecmp )
|
||||
VM_ComSearchFiles, // #19 float float Com_Search( string mask, float casecmp )
|
||||
VM_ComSearchFiles, // #19 float Com_Search( string mask, float casecmp )
|
||||
VM_ComSearchNames, // #20 string Com_SearchFilename( float num )
|
||||
VM_RandomLong, // #21 float RandomLong( float min, float max )
|
||||
VM_RandomFloat, // #22 float RandomFloat( float min, float max )
|
||||
VM_RandomVector, // #23 vector RandomVector( vector min, vector max )
|
||||
VM_CvarRegister, // #24 void Cvar_Register( string name, string value, float flags )
|
||||
VM_CvarSetValue, // #25 void Cvar_SetValue( string name, string value )
|
||||
VM_CvarGetValue, // #26 string Cvar_GetValue( string name )
|
||||
VM_CvarSetValue, // #25 void Cvar_SetValue( string name, float value )
|
||||
VM_CvarGetValue, // #26 float Cvar_GetValue( string name )
|
||||
VM_ComVA, // #27 string va( ... )
|
||||
VM_ComAtof, // #28 float atof( string s )
|
||||
VM_ComFtoa, // #29 string ftoa( float f )
|
||||
VM_ComAtov, // #30 vector atov( string s )
|
||||
VM_ComVtoa, // #31 string vtoa( vector v )
|
||||
VM_ComStrlen, // #32 float Com_Strlen( string text, float is_colortext )
|
||||
VM_TimeStamp, // #33 string Com_TimeStamp( float format )
|
||||
VM_ComStrlen, // #28 float strlen( string text )
|
||||
VM_TimeStamp, // #29 string Com_TimeStamp( float format )
|
||||
VM_LocalCmd, // #30 void LocalCmd( ... )
|
||||
NULL, // #31 -- reserved --
|
||||
NULL, // #32 -- reserved --
|
||||
NULL, // #33 -- reserved --
|
||||
NULL, // #34 -- reserved --
|
||||
NULL, // #35 -- reserved --
|
||||
NULL, // #36 -- reserved --
|
||||
|
@ -479,7 +1093,7 @@ NULL, // #40 -- reserved --
|
|||
VM_SpawnEdict, // #41 entity spawn( void )
|
||||
VM_RemoveEdict, // #42 void remove( entity ent )
|
||||
VM_NextEdict, // #43 entity nextent( entity ent )
|
||||
NULL, // #44 -- reserved --
|
||||
VM_CopyEdict, // #44 void copyentity( entity src, entity dst )
|
||||
NULL, // #45 -- reserved --
|
||||
NULL, // #46 -- reserved --
|
||||
NULL, // #47 -- reserved --
|
||||
|
@ -515,11 +1129,11 @@ VM_rint, // #72 float rint (float v)
|
|||
VM_floor, // #73 float floor(float v)
|
||||
VM_ceil, // #74 float ceil (float v)
|
||||
VM_fabs, // #75 float fabs (float f)
|
||||
VM_VectorNormalize, // #76 vector VectorNormalize( vector v )
|
||||
VM_VectorLength, // #77 float VectorLength( vector v )
|
||||
VM_mod, // #76 float fmod( float val, float m )
|
||||
NULL, // #77 -- reserved --
|
||||
NULL, // #78 -- reserved --
|
||||
NULL, // #79 -- reserved --
|
||||
NULL, // #80 -- reserved --
|
||||
VM_VectorNormalize, // #79 vector VectorNormalize( vector v )
|
||||
VM_VectorLength, // #80 float VectorLength( vector v )
|
||||
e10, e10 // #81 - #100 are reserved for future expansions
|
||||
};
|
||||
|
||||
|
|
|
@ -236,9 +236,65 @@ _inline edict_t *PRVM_EDICT_NUM( int n )
|
|||
// helper common functions
|
||||
const char *VM_VarArgs( int start_arg );
|
||||
bool VM_ValidateArgs( const char *builtin, int num_argc );
|
||||
void VM_ValidateString( const char *s );
|
||||
|
||||
// builtins and other general functions
|
||||
void VM_ConPrintf( void );
|
||||
void VM_ConDPrintf( void );
|
||||
void VM_HostError( void );
|
||||
void VM_SysExit( void );
|
||||
void VM_CmdArgv( void );
|
||||
void VM_CmdArgc( void );
|
||||
void VM_ComTrace( void );
|
||||
void VM_ComFileExists( void );
|
||||
void VM_ComFileSize( void );
|
||||
void VM_ComFileTime( void );
|
||||
void VM_ComLoadScript( void );
|
||||
void VM_ComResetScript( void );
|
||||
void VM_ComReadToken( void );
|
||||
void VM_ComFilterToken( void );
|
||||
void VM_ComSearchFiles( void );
|
||||
void VM_ComSearchNames( void );
|
||||
void VM_RandomLong( void );
|
||||
void VM_RandomFloat( void );
|
||||
void VM_RandomVector( void );
|
||||
void VM_CvarRegister( void );
|
||||
void VM_CvarSetValue( void );
|
||||
void VM_CvarGetValue( void );
|
||||
void VM_ComVA( void );
|
||||
void VM_ComStrlen( void );
|
||||
void VM_TimeStamp( void );
|
||||
void VM_LocalCmd( void );
|
||||
void VM_SpawnEdict( void );
|
||||
void VM_RemoveEdict( void );
|
||||
void VM_NextEdict( void );
|
||||
void VM_CopyEdict( void );
|
||||
void VM_FindEdict( void );
|
||||
void VM_FindField( void );
|
||||
void VM_FS_Open( void );
|
||||
void VM_FS_Close( void );
|
||||
void VM_FS_Gets( void );
|
||||
void VM_FS_Gete( void );
|
||||
void VM_FS_Puts( void );
|
||||
void VM_FS_Pute( void );
|
||||
void VM_min( void );
|
||||
void VM_max( void );
|
||||
void VM_bound( void );
|
||||
void VM_mod( void );
|
||||
void VM_pow( void );
|
||||
void VM_sin( void );
|
||||
void VM_cos( void );
|
||||
void VM_tan( void );
|
||||
void VM_asin( void );
|
||||
void VM_acos( void );
|
||||
void VM_atan( void );
|
||||
void VM_sqrt( void );
|
||||
void VM_rint( void );
|
||||
void VM_floor( void );
|
||||
void VM_ceil( void );
|
||||
void VM_fabs( void );
|
||||
void VM_VectorNormalize( void );
|
||||
void VM_VectorLength( void );
|
||||
|
||||
char *VM_GetTempString(void);
|
||||
void VM_CheckEmptyString (const char *s);
|
||||
|
@ -275,8 +331,6 @@ void VM_itof(void);
|
|||
void VM_ftoe(void);
|
||||
void VM_create (void);
|
||||
void VM_remove (void);
|
||||
void VM_find (void);
|
||||
void VM_findfloat (void);
|
||||
void VM_findchain (void);
|
||||
void VM_findchainfloat (void);
|
||||
void VM_findflags (void);
|
||||
|
|
|
@ -785,6 +785,8 @@ void PF_sprint( void )
|
|||
int num;
|
||||
char string[VM_STRINGTEMP_LENGTH];
|
||||
|
||||
//FIXME: allow to centerprint here
|
||||
|
||||
num = PRVM_G_EDICTNUM(OFS_PARM0);
|
||||
|
||||
if( num < 1 || num > maxclients->value || svs.clients[num - 1].state != cs_spawned )
|
||||
|
@ -1005,14 +1007,6 @@ void PF_sound (void)
|
|||
SV_StartSound (NULL, entity, channel, sound_idx, volume / 255.0f, attenuation, 0 );
|
||||
}
|
||||
|
||||
void PF_event( void )
|
||||
{
|
||||
edict_t *ent = PRVM_G_EDICT(OFS_PARM0);
|
||||
|
||||
// event effects
|
||||
ent->priv.sv->event = (int)PRVM_G_FLOAT(OFS_PARM1);
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
PF_ambientsound
|
||||
|
@ -1760,249 +1754,174 @@ void PF_spawnclient( void )
|
|||
//NOTE: intervals between various "interfaces" was leave for future expansions
|
||||
prvm_builtin_t vm_sv_builtins[] =
|
||||
{
|
||||
NULL, // #0
|
||||
NULL, // #0 (leave blank as default, but can include easter egg )
|
||||
|
||||
// network messaging
|
||||
PF_BeginMessage, // #1 void MsgBegin (float dest)
|
||||
PF_WriteByte, // #2 void WriteByte (float f)
|
||||
PF_WriteChar, // #3 void WriteChar (float f)
|
||||
PF_WriteShort, // #4 void WriteShort (float f)
|
||||
PF_WriteLong, // #5 void WriteLong (float f)
|
||||
PF_WriteFloat, // #6 void WriteFloat (float f)
|
||||
PF_WriteAngle, // #7 void WriteAngle (float f)
|
||||
PF_WriteCoord, // #8 void WriteCoord (float f)
|
||||
PF_WriteString, // #9 void WriteString (string s)
|
||||
PF_WriteEntity, // #10 void WriteEntity (entity s)
|
||||
PF_EndMessage, // #11 void MsgEnd(float to, vector pos, entity e)
|
||||
// system events
|
||||
VM_ConPrintf, // #1 void Con_Printf( ... )
|
||||
VM_ConDPrintf, // #2 void Con_DPrintf( float level, ... )
|
||||
VM_HostError, // #3 void Com_Error( ... )
|
||||
VM_SysExit, // #4 void Sys_Exit( void )
|
||||
VM_CmdArgv, // #5 string Cmd_Argv( float arg )
|
||||
VM_CmdArgc, // #6 float Cmd_Argc( void )
|
||||
NULL, // #7 -- reserved --
|
||||
NULL, // #8 -- reserved --
|
||||
NULL, // #9 -- reserved --
|
||||
NULL, // #10 -- reserved --
|
||||
|
||||
// common tools
|
||||
VM_ComTrace, // #11 void Com_Trace( float enable )
|
||||
VM_ComFileExists, // #12 float Com_FileExists( string filename )
|
||||
VM_ComFileSize, // #13 float Com_FileSize( string filename )
|
||||
VM_ComFileTime, // #14 float Com_FileTime( string filename )
|
||||
VM_ComLoadScript, // #15 float Com_LoadScript( string filename )
|
||||
VM_ComResetScript, // #16 void Com_ResetScript( void )
|
||||
VM_ComReadToken, // #17 string Com_ReadToken( float newline )
|
||||
VM_ComFilterToken, // #18 float Com_Filter( string mask, string s, float casecmp )
|
||||
VM_ComSearchFiles, // #19 float Com_Search( string mask, float casecmp )
|
||||
VM_ComSearchNames, // #20 string Com_SearchFilename( float num )
|
||||
VM_RandomLong, // #21 float RandomLong( float min, float max )
|
||||
VM_RandomFloat, // #22 float RandomFloat( float min, float max )
|
||||
VM_RandomVector, // #23 vector RandomVector( vector min, vector max )
|
||||
VM_CvarRegister, // #24 void Cvar_Register( string name, string value, float flags )
|
||||
VM_CvarSetValue, // #25 void Cvar_SetValue( string name, float value )
|
||||
VM_CvarGetValue, // #26 float Cvar_GetValue( string name )
|
||||
VM_ComVA, // #27 string va( ... )
|
||||
VM_ComStrlen, // #28 float strlen( string text )
|
||||
VM_TimeStamp, // #29 string Com_TimeStamp( float format )
|
||||
VM_LocalCmd, // #30 void LocalCmd( ... )
|
||||
NULL, // #31 -- reserved --
|
||||
NULL, // #32 -- reserved --
|
||||
NULL, // #33 -- reserved --
|
||||
NULL, // #34 -- reserved --
|
||||
NULL, // #35 -- reserved --
|
||||
NULL, // #36 -- reserved --
|
||||
NULL, // #37 -- reserved --
|
||||
NULL, // #38 -- reserved --
|
||||
NULL, // #39 -- reserved --
|
||||
NULL, // #40 -- reserved --
|
||||
|
||||
// quakec intrinsics ( compiler will be lookup this functions, don't remove or rename )
|
||||
VM_SpawnEdict, // #41 entity spawn( void )
|
||||
VM_RemoveEdict, // #42 void remove( entity ent )
|
||||
VM_NextEdict, // #43 entity nextent( entity ent )
|
||||
VM_CopyEdict, // #44 void copyentity( entity src, entity dst )
|
||||
NULL, // #45 -- reserved --
|
||||
NULL, // #46 -- reserved --
|
||||
NULL, // #47 -- reserved --
|
||||
NULL, // #48 -- reserved --
|
||||
NULL, // #49 -- reserved --
|
||||
NULL, // #50 -- reserved --
|
||||
|
||||
// filesystem
|
||||
VM_FS_Open, // #51 float fopen( string filename, float mode )
|
||||
VM_FS_Close, // #52 void fclose( float handle )
|
||||
VM_FS_Gets, // #53 string fgets( float handle )
|
||||
VM_FS_Gete, // #54 entity fgete( float handle )
|
||||
VM_FS_Puts, // #55 void fputs( float handle, string s )
|
||||
VM_FS_Pute, // #56 void fpute( float handle, entity e )
|
||||
NULL, // #57 -- reserved --
|
||||
NULL, // #58 -- reserved --
|
||||
NULL, // #59 -- reserved --
|
||||
NULL, // #60 -- reserved --
|
||||
|
||||
// mathlib
|
||||
VM_min, // #12 float min(float a, float b )
|
||||
VM_max, // #13 float max(float a, float b )
|
||||
VM_bound, // #14 float bound(float min, float val, float max)
|
||||
VM_pow, // #15 float pow(float x, float y)
|
||||
VM_sin, // #16 float sin(float f)
|
||||
VM_cos, // #17 float cos(float f)
|
||||
VM_sqrt, // #18 float sqrt(float f)
|
||||
VM_rint, // #19 float rint (float v)
|
||||
VM_floor, // #20 float floor(float v)
|
||||
VM_ceil, // #21 float ceil (float v)
|
||||
VM_fabs, // #22 float fabs (float f)
|
||||
VM_random_long, // #23 float random_long( void )
|
||||
VM_random_float, // #24 float random_float( void )
|
||||
NULL, // #25
|
||||
NULL, // #26
|
||||
NULL, // #27
|
||||
NULL, // #28
|
||||
NULL, // #29
|
||||
NULL, // #30
|
||||
|
||||
// vector mathlib
|
||||
VM_normalize, // #31 vector normalize(vector v)
|
||||
VM_veclength, // #32 float veclength(vector v)
|
||||
VM_vectoyaw, // #33 float vectoyaw(vector v)
|
||||
VM_vectoangles, // #34 vector vectoangles(vector v)
|
||||
VM_randomvec, // #35 vector randomvec( void )
|
||||
VM_vectorvectors, // #36 void vectorvectors(vector dir)
|
||||
VM_makevectors, // #37 void makevectors(vector dir)
|
||||
VM_makevectors2, // #38 void makevectors2(vector dir)
|
||||
NULL, // #39
|
||||
NULL, // #40
|
||||
|
||||
// stdlib functions
|
||||
VM_atof, // #41 float atof(string s)
|
||||
VM_ftoa, // #42 string ftoa(float s)
|
||||
VM_vtoa, // #43 string vtoa(vector v)
|
||||
VM_atov, // #44 vector atov(string s)
|
||||
VM_print, // #45 void Msg( ... )
|
||||
VM_wprint, // #46 void MsgWarn( ... )
|
||||
VM_objerror, // #47 void Error( ... )
|
||||
VM_bprint, // #48 void bprint(string s)
|
||||
PF_sprint, // #49 void sprint(entity client, string s)
|
||||
PF_centerprint, // #50 void centerprint(entity client, strings)
|
||||
VM_cvar, // #51 float cvar(string s)
|
||||
VM_cvar_set, // #52 void cvar_set(string var, string val)
|
||||
VM_allocstring, // #53 string AllocString(string s)
|
||||
VM_freestring, // #54 void FreeString(string s)
|
||||
VM_strlen, // #55 float strlen(string s)
|
||||
VM_strcat, // #56 string strcat(string s1, string s2)
|
||||
VM_argv, // #57 string argv( float parm )
|
||||
NULL, // #58
|
||||
NULL, // #59
|
||||
NULL, // #60
|
||||
|
||||
// internal debugger
|
||||
VM_break, // #61 void break( void )
|
||||
VM_crash, // #62 void crash( void )
|
||||
VM_coredump, // #63 void coredump( void )
|
||||
VM_stackdump, // #64 void stackdump( void )
|
||||
VM_traceon, // #65 void trace_on( void )
|
||||
VM_traceoff, // #66 void trace_off( void )
|
||||
VM_eprint, // #67 void dump_edict(entity e)
|
||||
VM_nextent, // #68 entity nextent(entity e)
|
||||
NULL, // #69
|
||||
NULL, // #70
|
||||
VM_min, // #61 float min(float a, float b )
|
||||
VM_max, // #62 float max(float a, float b )
|
||||
VM_bound, // #63 float bound(float min, float val, float max)
|
||||
VM_pow, // #64 float pow(float x, float y)
|
||||
VM_sin, // #65 float sin(float f)
|
||||
VM_cos, // #66 float cos(float f)
|
||||
VM_tan, // #67 float tan(float f)
|
||||
VM_asin, // #68 float asin(float f)
|
||||
VM_acos, // #69 float acos(float f)
|
||||
VM_atan, // #70 float atan(float f)
|
||||
VM_sqrt, // #71 float sqrt(float f)
|
||||
VM_rint, // #72 float rint (float v)
|
||||
VM_floor, // #73 float floor(float v)
|
||||
VM_ceil, // #74 float ceil (float v)
|
||||
VM_fabs, // #75 float fabs (float f)
|
||||
VM_mod, // #76 float fmod( float val, float m )
|
||||
NULL, // #77 -- reserved --
|
||||
NULL, // #78 -- reserved --
|
||||
VM_VectorNormalize, // #79 vector VectorNormalize( vector v )
|
||||
VM_VectorLength, // #80 float VectorLength( vector v )
|
||||
e10, e10, // #81 - #100 are reserved for future expansions
|
||||
|
||||
// engine functions (like half-life enginefuncs_s)
|
||||
PF_precache_model, // #71 float precache_model(string s)
|
||||
PF_precache_sound, // #72 float precache_sound(string s)
|
||||
PF_setmodel, // #73 float setmodel(entity e, string m)
|
||||
PF_modelindex, // #74 float model_index(string s)
|
||||
PF_decalindex, // #75 float decal_index(string s)
|
||||
PF_imageindex, // #76 float image_index(string s)
|
||||
PF_setsize, // #77 void setsize(entity e, vector min, vector max)
|
||||
PF_changelevel, // #78 void changelevel(string mapname, string spotname)
|
||||
PF_changeyaw, // #79 void ChangeYaw( void )
|
||||
PF_changepitch, // #80 void ChangePitch( void )
|
||||
VM_find, // #81 entity find(entity start, .string fld, string match)
|
||||
PF_getlightlevel, // #82 float getEntityIllum( entity e )
|
||||
PF_findradius, // #83 entity FindInSphere(vector org, float rad)
|
||||
PF_inpvs, // #84 float InPVS( vector v1, vector v2 )
|
||||
PF_inphs, // #85 float InPHS( vector v1, vector v2 )
|
||||
PF_create, // #86 entity create( string name, string model, vector org )
|
||||
VM_remove, // #87 void remove( entity e )
|
||||
PF_droptofloor, // #88 float droptofloor( void )
|
||||
PF_walkmove, // #89 float walkmove(float yaw, float dist)
|
||||
PF_setorigin, // #90 void setorigin(entity e, vector o)
|
||||
PF_sound, // #91 void sound(entity e, float chan, string samp, float vol, float attn)
|
||||
PF_ambientsound, // #92 void ambientsound(entity e, string samp)
|
||||
PF_traceline, // #93 void traceline(vector v1, vector v2, float mask, entity ignore)
|
||||
PF_tracetoss, // #94 void tracetoss (entity e, entity ignore)
|
||||
PF_tracebox, // #95 void tracebox (vector v1, vector mins, vector maxs, vector v2, float mask, entity ignore)
|
||||
PF_checkbottom, // #96 float checkbottom(entity e)
|
||||
PF_lightstyle, // #97 void lightstyle(float style, string value)
|
||||
PF_pointcontents, // #98 float pointcontents(vector v)
|
||||
PF_aim, // #99 vector aim(entity e, float speed)
|
||||
VM_servercmd, // #100 void server_command( string command )
|
||||
VM_clientcmd, // #101 void client_command( entity e, string s)
|
||||
PF_particle, // #102 void particle(vector o, vector d, float color, float count)
|
||||
PF_areaportalstate, // #103 void areaportal_state( float num, float state )
|
||||
PF_setstats, // #104 void setstats(entity e, float f, string stats)
|
||||
PF_configstring, // #105 void configstring(float num, string s)
|
||||
PF_makestatic, // #106 void makestatic(entity e)
|
||||
PF_modelframes, // #107 float model_frames(float modelindex)
|
||||
PF_event, // #108 void set_effect( entity e, float effect )
|
||||
NULL, // #109
|
||||
NULL, // #110
|
||||
NULL, // #111
|
||||
NULL, // #112
|
||||
NULL, // #113
|
||||
NULL, // #114
|
||||
NULL, // #115
|
||||
NULL, // #116
|
||||
NULL, // #117
|
||||
NULL, // #118
|
||||
NULL, // #119
|
||||
e10, e10, e10, e10, e10, e10, e10, e10, // #120-199
|
||||
NULL, // #200
|
||||
NULL, // #201
|
||||
NULL, // #202
|
||||
NULL, // #203
|
||||
NULL, // #204
|
||||
NULL, // #205
|
||||
NULL, // #206
|
||||
NULL, // #207
|
||||
NULL, // #208
|
||||
NULL, // #209
|
||||
NULL, // #210
|
||||
NULL, // #211
|
||||
NULL, // #212
|
||||
NULL, // #213
|
||||
NULL, // #214
|
||||
NULL, // #215
|
||||
NULL, // #216
|
||||
NULL, // #217
|
||||
NULL, // #218
|
||||
NULL, // #219
|
||||
e10, // #220-#229
|
||||
e10, // #230-#239
|
||||
e10, // #240-#249
|
||||
e10, // #250-#259
|
||||
e10, // #260-#269
|
||||
e10, // #270-#279
|
||||
e10, // #280-#289
|
||||
e10, // #290-#299
|
||||
e10, e10, e10, e10, e10, e10, e10, e10, e10, e10, // #300-399
|
||||
NULL, // #400
|
||||
NULL, // #401
|
||||
VM_findchain, // #402 entity(.string fld, string match) findchain (DP_QC_FINDCHAIN)
|
||||
VM_findchainfloat, // #403 entity(.float fld, float match) findchainfloat (DP_QC_FINDCHAINFLOAT)
|
||||
NULL, // #404 void(vector org, string modelname, float startframe, float endframe, float framerate) effect (DP_SV_EFFECT)
|
||||
NULL, // #405 void(vector org, vector velocity, float howmany) te_blood (DP_TE_BLOOD)
|
||||
NULL, // #406 void(vector mincorner, vector maxcorner, float explosionspeed, float howmany) te_bloodshower (DP_TE_BLOODSHOWER)
|
||||
NULL, // #407 void(vector org, vector color) te_explosionrgb (DP_TE_EXPLOSIONRGB)
|
||||
NULL, // #408 void(vector mincorner, vector maxcorner, vector vel, float howmany, float color, float gravityflag, float randomveljitter) te_particlecube (DP_TE_PARTICLECUBE)
|
||||
NULL, // #409 void(vector mincorner, vector maxcorner, vector vel, float howmany, float color) te_particlerain (DP_TE_PARTICLERAIN)
|
||||
NULL, // #410 void(vector mincorner, vector maxcorner, vector vel, float howmany, float color) te_particlesnow (DP_TE_PARTICLESNOW)
|
||||
NULL, // #411 void(vector org, vector vel, float howmany) te_spark (DP_TE_SPARK)
|
||||
NULL, // #412 void(vector org) te_gunshotquad (DP_QUADEFFECTS1)
|
||||
NULL, // #413 void(vector org) te_spikequad (DP_QUADEFFECTS1)
|
||||
NULL, // #414 void(vector org) te_superspikequad (DP_QUADEFFECTS1)
|
||||
NULL, // #415 void(vector org) te_explosionquad (DP_QUADEFFECTS1)
|
||||
NULL, // #416 void(vector org) te_smallflash (DP_TE_SMALLFLASH)
|
||||
NULL, // #417 void(vector org, float radius, float lifetime, vector color) te_customflash (DP_TE_CUSTOMFLASH)
|
||||
NULL, // #418 void(vector org) te_gunshot (DP_TE_STANDARDEFFECTBUILTINS)
|
||||
NULL, // #419 void(vector org) te_spike (DP_TE_STANDARDEFFECTBUILTINS)
|
||||
NULL, // #420 void(vector org) te_superspike (DP_TE_STANDARDEFFECTBUILTINS)
|
||||
NULL, // #421 void(vector org) te_explosion (DP_TE_STANDARDEFFECTBUILTINS)
|
||||
NULL, // #422 void(vector org) te_tarexplosion (DP_TE_STANDARDEFFECTBUILTINS)
|
||||
NULL, // #423 void(vector org) te_wizspike (DP_TE_STANDARDEFFECTBUILTINS)
|
||||
NULL, // #424 void(vector org) te_knightspike (DP_TE_STANDARDEFFECTBUILTINS)
|
||||
NULL, // #425 void(vector org) te_lavasplash (DP_TE_STANDARDEFFECTBUILTINS)
|
||||
NULL, // #426 void(vector org) te_teleport (DP_TE_STANDARDEFFECTBUILTINS)
|
||||
NULL, // #427 void(vector org, float colorstart, float colorlength) te_explosion2 (DP_TE_STANDARDEFFECTBUILTINS)
|
||||
NULL, // #428 void(entity own, vector start, vector end) te_lightning1 (DP_TE_STANDARDEFFECTBUILTINS)
|
||||
NULL, // #429 void(entity own, vector start, vector end) te_lightning2 (DP_TE_STANDARDEFFECTBUILTINS)
|
||||
NULL, // #430 void(entity own, vector start, vector end) te_lightning3 (DP_TE_STANDARDEFFECTBUILTINS)
|
||||
NULL, // #431 void(entity own, vector start, vector end) te_beam (DP_TE_STANDARDEFFECTBUILTINS)
|
||||
NULL, // #432
|
||||
NULL, // #433 void(vector org) te_plasmaburn (DP_TE_PLASMABURN)
|
||||
NULL, // #434 float(entity e, float s) getsurfacenumpoints (DP_QC_GETSURFACE)
|
||||
NULL, // #435 vector(entity e, float s, float n) getsurfacepoint (DP_QC_GETSURFACE)
|
||||
NULL, // #436 vector(entity e, float s) getsurfacenormal (DP_QC_GETSURFACE)
|
||||
NULL, // #437 string(entity e, float s) getsurfacetexture (DP_QC_GETSURFACE)
|
||||
NULL, // #438 float(entity e, vector p) getsurfacenearpoint (DP_QC_GETSURFACE)
|
||||
NULL, // #439 vector(entity e, float s, vector p) getsurfaceclippedpoint (DP_QC_GETSURFACE)
|
||||
NULL, // #440
|
||||
VM_tokenize, // #441 float(string s) tokenize (KRIMZON_SV_PARSECLIENTCOMMAND)
|
||||
VM_argv, // #442 string(float n) argv (KRIMZON_SV_PARSECLIENTCOMMAND)
|
||||
NULL, // #443 void(entity e, entity tagentity, string tagname) setattachment (DP_GFX_QUAKE3MODELTAGS)
|
||||
VM_search_begin, // #444 float(string pattern, float caseinsensitive, float quiet) search_begin (DP_FS_SEARCH)
|
||||
VM_search_end, // #445 void(float handle) search_end (DP_FS_SEARCH)
|
||||
VM_search_getsize, // #446 float(float handle) search_getsize (DP_FS_SEARCH)
|
||||
VM_search_getfilename, // #447 string(float handle, float num) search_getfilename (DP_FS_SEARCH)
|
||||
VM_cvar_string, // #448 string(string s) cvar_string (DP_QC_CVAR_STRING)
|
||||
VM_findflags, // #449 entity(entity start, .float fld, float match) findflags (DP_QC_FINDFLAGS)
|
||||
VM_findchainflags, // #450 entity(.float fld, float match) findchainflags (DP_QC_FINDCHAINFLAGS)
|
||||
NULL, // #451 float(entity ent, string tagname) gettagindex (DP_QC_GETTAGINFO)
|
||||
NULL, // #452 vector(entity ent, float tagindex) gettaginfo (DP_QC_GETTAGINFO)
|
||||
PF_dropclient, // #453 void(entity clent) dropclient (DP_SV_DROPCLIENT)
|
||||
PF_spawnclient, // #454 entity() spawnclient (DP_SV_BOTCLIENT)
|
||||
NULL, // #455
|
||||
NULL, // #456
|
||||
NULL, // #457 void(vector org, vector vel, float howmany) te_flamejet = #457 (DP_TE_FLAMEJET)
|
||||
NULL, // #458
|
||||
NULL, // #459
|
||||
VM_buf_create, // #460 float() buf_create (DP_QC_STRINGBUFFERS)
|
||||
VM_buf_del, // #461 void(float bufhandle) buf_del (DP_QC_STRINGBUFFERS)
|
||||
VM_buf_getsize, // #462 float(float bufhandle) buf_getsize (DP_QC_STRINGBUFFERS)
|
||||
VM_buf_copy, // #463 void(float bufhandle_from, float bufhandle_to) buf_copy (DP_QC_STRINGBUFFERS)
|
||||
VM_buf_sort, // #464 void(float bufhandle, float sortpower, float backward) buf_sort (DP_QC_STRINGBUFFERS)
|
||||
VM_buf_implode, // #465 string(float bufhandle, string glue) buf_implode (DP_QC_STRINGBUFFERS)
|
||||
VM_bufstr_get, // #466 string(float bufhandle, float string_index) bufstr_get (DP_QC_STRINGBUFFERS)
|
||||
VM_bufstr_set, // #467 void(float bufhandle, float string_index, string str) bufstr_set (DP_QC_STRINGBUFFERS)
|
||||
VM_bufstr_add, // #468 float(float bufhandle, string str, float order) bufstr_add (DP_QC_STRINGBUFFERS)
|
||||
VM_bufstr_free, // #469 void(float bufhandle, float string_index) bufstr_free (DP_QC_STRINGBUFFERS)
|
||||
NULL, // #470
|
||||
NULL, // #471
|
||||
NULL, // #472
|
||||
NULL, // #473
|
||||
NULL, // #474
|
||||
NULL, // #475
|
||||
NULL, // #476
|
||||
NULL, // #477
|
||||
NULL, // #478
|
||||
NULL, // #479
|
||||
e10, e10 // #480-499 (LordHavoc)
|
||||
PF_precache_model, // #101 float precache_model(string s)
|
||||
PF_precache_sound, // #102 float precache_sound(string s)
|
||||
PF_setmodel, // #103 float setmodel(entity e, string m)
|
||||
PF_modelindex, // #104 float model_index(string s)
|
||||
PF_modelframes, // #105 float model_frames(float modelindex)
|
||||
PF_setsize, // #106 void setsize(entity e, vector min, vector max)
|
||||
PF_changelevel, // #107 void changelevel(string mapname, string spotname)
|
||||
NULL, // #108 getSpawnParms
|
||||
NULL, // #109 SaveSpawnParms
|
||||
VM_vectoyaw, // #110 float vectoyaw(vector v)
|
||||
VM_vectoangles, // #111 vector vectoangles(vector v)
|
||||
NULL, // #112 moveToOrigin
|
||||
PF_changeyaw, // #113 void ChangeYaw( void )
|
||||
PF_changepitch, // #114 void ChangePitch( void )
|
||||
VM_FindEdict, // #115 entity find(entity start, .string fld, string match)
|
||||
PF_getlightlevel, // #116 float getEntityIllum( entity e )
|
||||
PF_findradius, // #117 entity FindInSphere(vector org, float rad)
|
||||
PF_inpvs, // #118 float EntitiesInPVS( vector v1, vector v2 )
|
||||
PF_inphs, // #119 float EntitiesInPHS( vector v1, vector v2 )
|
||||
VM_makevectors, // #120 void makevectors(vector dir)
|
||||
NULL, // #121 AngleVectors (really need ?)
|
||||
VM_SpawnEdict, // #122 entity create( void )
|
||||
VM_RemoveEdict, // #123 void remove( entity ent )
|
||||
PF_create, // #124 createNamedEntity
|
||||
PF_makestatic, // #125 void makestatic(entity e)
|
||||
NULL, // #126 isEntOnFloor
|
||||
PF_droptofloor, // #127 float droptofloor( void )
|
||||
PF_walkmove, // #128 float walkmove(float yaw, float dist)
|
||||
PF_setorigin, // #129 void setorigin(entity e, vector o)
|
||||
PF_sound, // #130 void EmitSound(entity e, float chan, string samp, float vol, float attn)
|
||||
PF_ambientsound, // #131 void EmitAmbientSound(entity e, string samp)
|
||||
PF_traceline, // #132 void traceline(vector v1, vector v2, float mask, entity ignore)
|
||||
PF_tracetoss, // #133 void tracetoss (entity e, entity ignore)
|
||||
NULL, // #134 traceMonsterHull
|
||||
PF_tracebox, // #135 void tracebox (vector v1, vector mins, vector maxs, vector v2, float mask, entity ignore)
|
||||
NULL, // #136 traceModel
|
||||
NULL, // #137 traceTexture
|
||||
NULL, // #138 traceSphere
|
||||
PF_aim, // #139 vector aim(entity e, float speed)
|
||||
VM_servercmd, // #140 void server_command( string command )
|
||||
NULL, // #141 server_execute
|
||||
VM_clientcmd, // #142 void client_command( entity e, string s)
|
||||
PF_particle, // #143 void particle(vector o, vector d, float color, float count)
|
||||
PF_lightstyle, // #144 void lightstyle(float style, string value)
|
||||
PF_decalindex, // #145 float decal_index(string s)
|
||||
PF_pointcontents, // #146 float pointcontents(vector v)
|
||||
PF_BeginMessage, // #147 void MsgBegin (float dest)
|
||||
PF_EndMessage, // #148 void MsgEnd(float to, vector pos, entity e)
|
||||
PF_WriteByte, // #149 void WriteByte (float f)
|
||||
PF_WriteChar, // #150 void WriteChar (float f)
|
||||
PF_WriteShort, // #151 void WriteShort (float f)
|
||||
PF_WriteLong, // #152 void WriteLong (float f)
|
||||
PF_WriteAngle, // #153 void WriteAngle (float f)
|
||||
PF_WriteCoord, // #154 void WriteCoord (float f)
|
||||
PF_WriteString, // #155 void WriteString (string s)
|
||||
PF_WriteEntity, // #156 void WriteEntity (entity s)
|
||||
NULL, // #157 getModelPtr
|
||||
NULL, // #158 regUserMsg
|
||||
PF_checkbottom, // #159 float checkbottom(entity e)
|
||||
NULL, // #160 getBonePosition
|
||||
PF_sprint, // #161 void ClientPrint(entity client, string s)
|
||||
VM_bprint, // #162 void ServerPrint(string s)
|
||||
NULL, // #163 getAttachment
|
||||
NULL, // #164 setView
|
||||
NULL, // #165 crosshairangle
|
||||
PF_areaportalstate, // #166 void areaportal_state( float num, float state )
|
||||
NULL, // #167 compareFileTime
|
||||
PF_setstats, // #168 void setstats(entity e, float f, string stats)
|
||||
NULL, // #169 GetInfoKeyBuffer
|
||||
NULL, // #170 InfoKeyValue
|
||||
NULL, // #171 SetKeyValue
|
||||
NULL, // #172 SetClientKeyValue
|
||||
PF_configstring, // #173 void configstring(float num, string s)
|
||||
NULL, // #174 staticDecal
|
||||
};
|
||||
|
||||
const int vm_sv_numbuiltins = sizeof(vm_sv_builtins) / sizeof(prvm_builtin_t); //num of builtins
|
||||
|
|
Binary file not shown.
458
engine/vm_cmds.c
458
engine/vm_cmds.c
|
@ -481,23 +481,6 @@ void VM_break (void)
|
|||
|
||||
//============================================================================
|
||||
|
||||
/*
|
||||
=================
|
||||
VM_localcmd
|
||||
|
||||
Sends text over to the client's execution buffer
|
||||
|
||||
[localcmd (string, ...) or]
|
||||
cmd (string, ...)
|
||||
=================
|
||||
*/
|
||||
void VM_localcmd (void)
|
||||
{
|
||||
char string[VM_STRINGTEMP_LENGTH];
|
||||
VM_VarString(0, string, sizeof(string));
|
||||
Cbuf_AddText(string);
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
VM_cvar
|
||||
|
@ -598,24 +581,6 @@ void VM_ftoa (void)
|
|||
PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString(s);
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_fabs
|
||||
|
||||
float fabs(float)
|
||||
=========
|
||||
*/
|
||||
|
||||
void VM_fabs (void)
|
||||
{
|
||||
float v;
|
||||
|
||||
VM_SAFEPARMCOUNT(1,VM_fabs);
|
||||
|
||||
v = PRVM_G_FLOAT(OFS_PARM0);
|
||||
PRVM_G_FLOAT(OFS_RETURN) = fabs(v);
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_vtoa
|
||||
|
@ -745,88 +710,6 @@ void VM_remove (void)
|
|||
else PRVM_ED_Free (ed);
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_find
|
||||
|
||||
entity find(entity start, .string field, string match)
|
||||
=========
|
||||
*/
|
||||
|
||||
void VM_find (void)
|
||||
{
|
||||
int e;
|
||||
int f;
|
||||
const char *s, *t;
|
||||
edict_t *ed;
|
||||
|
||||
VM_SAFEPARMCOUNT(3,VM_find);
|
||||
|
||||
e = PRVM_G_EDICTNUM(OFS_PARM0);
|
||||
f = PRVM_G_INT(OFS_PARM1);
|
||||
s = PRVM_G_STRING(OFS_PARM2);
|
||||
|
||||
// LordHavoc: apparently BloodMage does a find(world, weaponmodel, "") and
|
||||
// expects it to find all the monsters, so we must be careful to support
|
||||
// searching for ""
|
||||
if (!s) s = "";
|
||||
|
||||
for (e++ ; e < prog->num_edicts ; e++)
|
||||
{
|
||||
prog->xfunction->builtinsprofile++;
|
||||
ed = PRVM_EDICT_NUM(e);
|
||||
if (ed->priv.ed->free)
|
||||
continue;
|
||||
t = PRVM_E_STRING(ed,f);
|
||||
if (!t) t = "";
|
||||
if (!strcmp(t,s))
|
||||
{
|
||||
VM_RETURN_EDICT(ed);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
VM_RETURN_EDICT(prog->edicts);
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_findfloat
|
||||
|
||||
entity findfloat(entity start, .float field, float match)
|
||||
entity findentity(entity start, .entity field, entity match)
|
||||
=========
|
||||
*/
|
||||
// LordHavoc: added this for searching float, int, and entity reference fields
|
||||
void VM_findfloat (void)
|
||||
{
|
||||
int e;
|
||||
int f;
|
||||
float s;
|
||||
edict_t *ed;
|
||||
|
||||
VM_SAFEPARMCOUNT(3,VM_findfloat);
|
||||
|
||||
e = PRVM_G_EDICTNUM(OFS_PARM0);
|
||||
f = PRVM_G_INT(OFS_PARM1);
|
||||
s = PRVM_G_FLOAT(OFS_PARM2);
|
||||
|
||||
for (e++ ; e < prog->num_edicts ; e++)
|
||||
{
|
||||
prog->xfunction->builtinsprofile++;
|
||||
ed = PRVM_EDICT_NUM(e);
|
||||
if (ed->priv.ed->free)
|
||||
continue;
|
||||
if (PRVM_E_FLOAT(ed,f) == s)
|
||||
{
|
||||
VM_RETURN_EDICT(ed);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
VM_RETURN_EDICT(prog->edicts);
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_findchain
|
||||
|
@ -1100,52 +983,6 @@ void VM_eprint (void)
|
|||
PRVM_ED_Print(PRVM_G_EDICT(OFS_PARM0));
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_rint
|
||||
|
||||
float rint(float)
|
||||
=========
|
||||
*/
|
||||
void VM_rint (void)
|
||||
{
|
||||
float f;
|
||||
VM_SAFEPARMCOUNT(1,VM_rint);
|
||||
|
||||
f = PRVM_G_FLOAT(OFS_PARM0);
|
||||
if (f > 0) PRVM_G_FLOAT(OFS_RETURN) = floor(f + 0.5);
|
||||
else PRVM_G_FLOAT(OFS_RETURN) = ceil(f - 0.5);
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_floor
|
||||
|
||||
float floor(float)
|
||||
=========
|
||||
*/
|
||||
void VM_floor (void)
|
||||
{
|
||||
VM_SAFEPARMCOUNT(1,VM_floor);
|
||||
|
||||
PRVM_G_FLOAT(OFS_RETURN) = floor(PRVM_G_FLOAT(OFS_PARM0));
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_ceil
|
||||
|
||||
float ceil(float)
|
||||
=========
|
||||
*/
|
||||
void VM_ceil (void)
|
||||
{
|
||||
VM_SAFEPARMCOUNT(1,VM_ceil);
|
||||
|
||||
PRVM_G_FLOAT(OFS_RETURN) = ceil(PRVM_G_FLOAT(OFS_PARM0));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=============
|
||||
VM_nextent
|
||||
|
@ -1260,64 +1097,6 @@ void VM_registercvar (void)
|
|||
PRVM_G_FLOAT(OFS_RETURN) = 1; // success
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
VM_min
|
||||
|
||||
returns the minimum of two supplied floats
|
||||
|
||||
float min(float a, float b)
|
||||
=================
|
||||
*/
|
||||
void VM_min (void)
|
||||
{
|
||||
PRVM_G_FLOAT(OFS_RETURN) = min(PRVM_G_FLOAT(OFS_PARM0), PRVM_G_FLOAT(OFS_PARM1));
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
VM_max
|
||||
|
||||
returns the maximum of two supplied floats
|
||||
|
||||
float max(float a, float b)
|
||||
=================
|
||||
*/
|
||||
void VM_max (void)
|
||||
{
|
||||
PRVM_G_FLOAT(OFS_RETURN) = max(PRVM_G_FLOAT(OFS_PARM0), PRVM_G_FLOAT(OFS_PARM1));
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
VM_bound
|
||||
|
||||
returns number bounded by supplied range
|
||||
|
||||
float bound(float min, float value, float max)
|
||||
=================
|
||||
*/
|
||||
void VM_bound (void)
|
||||
{
|
||||
VM_SAFEPARMCOUNT(3,VM_bound);
|
||||
PRVM_G_FLOAT(OFS_RETURN) = bound(PRVM_G_FLOAT(OFS_PARM0), PRVM_G_FLOAT(OFS_PARM1), PRVM_G_FLOAT(OFS_PARM2));
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
VM_pow
|
||||
|
||||
returns a raised to power b
|
||||
|
||||
float pow(float a, float b)
|
||||
=================
|
||||
*/
|
||||
void VM_pow (void)
|
||||
{
|
||||
VM_SAFEPARMCOUNT(2,VM_pow);
|
||||
PRVM_G_FLOAT(OFS_RETURN) = pow(PRVM_G_FLOAT(OFS_PARM0), PRVM_G_FLOAT(OFS_PARM1));
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
VM_copyentity
|
||||
|
@ -1860,20 +1639,6 @@ void VM_gettime(void)
|
|||
PRVM_G_FLOAT(OFS_RETURN) = (float) *prog->time;
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_loadfromdata
|
||||
|
||||
loadfromdata(string data)
|
||||
=========
|
||||
*/
|
||||
void VM_loadfromdata(void)
|
||||
{
|
||||
VM_SAFEPARMCOUNT(1,VM_loadentsfromfile);
|
||||
|
||||
PRVM_ED_LoadFromFile(PRVM_G_STRING(OFS_PARM0));
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
VM_parseentitydata
|
||||
|
@ -1902,57 +1667,6 @@ void VM_parseentitydata(void)
|
|||
PRVM_ED_ParseEdict (data, ent);
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_loadfromfile
|
||||
|
||||
loadfromfile(string file)
|
||||
=========
|
||||
*/
|
||||
void VM_loadfromfile(void)
|
||||
{
|
||||
const char *filename;
|
||||
char *data;
|
||||
|
||||
VM_SAFEPARMCOUNT(1,VM_loadfromfile);
|
||||
|
||||
filename = PRVM_G_STRING(OFS_PARM0);
|
||||
// .. is parent directory on many platforms
|
||||
// / is parent directory on Amiga
|
||||
// : is root of drive on Amiga (also used as a directory separator on Mac, but / works there too, so that's a bad idea)
|
||||
// \ is a windows-ism (so it's naughty to use it, / works on all platforms)
|
||||
if ((filename[0] == '.' && filename[1] == '.') || filename[0] == '/' || strrchr(filename, ':') || strrchr(filename, '\\'))
|
||||
{
|
||||
PRVM_G_FLOAT(OFS_RETURN) = -4;
|
||||
VM_Warning("VM_loadfromfile: %s dangerous or non-portable filename \"%s\" not allowed. (contains : or \\ or begins with .. or /)\n", PRVM_NAME, filename);
|
||||
return;
|
||||
}
|
||||
|
||||
// not conform with VM_fopen
|
||||
data = (char *)FS_LoadFile(filename, NULL);
|
||||
if (data == NULL) PRVM_G_FLOAT(OFS_RETURN) = -1;
|
||||
PRVM_ED_LoadFromFile( data );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_modulo
|
||||
|
||||
float mod(float val, float m)
|
||||
=========
|
||||
*/
|
||||
void VM_modulo(void)
|
||||
{
|
||||
int val, m;
|
||||
VM_SAFEPARMCOUNT(2,VM_module);
|
||||
|
||||
val = (int) PRVM_G_FLOAT(OFS_PARM0);
|
||||
m = (int) PRVM_G_FLOAT(OFS_PARM1);
|
||||
|
||||
PRVM_G_FLOAT(OFS_RETURN) = (float) (val % m);
|
||||
}
|
||||
|
||||
void VM_Search_Init(void)
|
||||
{
|
||||
int i;
|
||||
|
@ -2143,179 +1857,7 @@ void VM_iscachedpic(void)
|
|||
PRVM_G_FLOAT(OFS_RETURN) = false;
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_precache_pic
|
||||
|
||||
string precache_pic(string pic)
|
||||
=========
|
||||
*/
|
||||
void VM_precache_pic(void)
|
||||
{
|
||||
const char *s;
|
||||
|
||||
VM_SAFEPARMCOUNT(1, VM_precache_pic);
|
||||
|
||||
s = PRVM_G_STRING(OFS_PARM0);
|
||||
PRVM_G_INT(OFS_RETURN) = PRVM_G_INT(OFS_PARM0);
|
||||
|
||||
if(!s) PRVM_ERROR ("VM_precache_pic: %s: NULL", PRVM_NAME);
|
||||
|
||||
VM_CheckEmptyString (s);
|
||||
|
||||
re->RegisterPic((char *)s); //may return empty frame
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_drawcharacter
|
||||
|
||||
float drawcharacter(vector position, float character, vector scale, vector rgb, float alpha, float flag)
|
||||
=========
|
||||
*/
|
||||
void VM_drawcharacter(void)
|
||||
{
|
||||
char character;
|
||||
float *pos, *rgb, *scale, alpha;
|
||||
|
||||
VM_SAFEPARMCOUNT(5, VM_drawcharacter);
|
||||
character = (char)PRVM_G_FLOAT(OFS_PARM1);
|
||||
if(character == 0)
|
||||
{
|
||||
PRVM_G_FLOAT(OFS_RETURN) = -1;
|
||||
VM_Warning("VM_drawcharacter: %s passed null character !\n", PRVM_NAME);
|
||||
return;
|
||||
}
|
||||
|
||||
pos = PRVM_G_VECTOR(OFS_PARM0);
|
||||
scale = PRVM_G_VECTOR(OFS_PARM2);
|
||||
rgb = PRVM_G_VECTOR(OFS_PARM3);
|
||||
alpha = PRVM_G_FLOAT(OFS_PARM4);
|
||||
|
||||
if(pos[2]) Msg("VM_drawcharacter: z value from \"pos\" discarded\n" );
|
||||
if(scale[2]) Msg("VM_drawcharacter: z value from \"scale\" discarded\n" );
|
||||
|
||||
re->SetColor( GetRGBA(rgb[0], rgb[1], rgb[2], alpha ));
|
||||
SCR_DrawChar( pos[0], pos[1], scale[0], scale[1], character );
|
||||
re->SetColor( NULL );
|
||||
PRVM_G_FLOAT(OFS_RETURN) = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_drawstring
|
||||
|
||||
float drawstring(vector position, string text, vector scale, vector rgb, float alpha, float flag)
|
||||
=========
|
||||
*/
|
||||
void VM_drawstring(void)
|
||||
{
|
||||
float *pos, *scale, *rgb, alpha;
|
||||
const char *string;
|
||||
int flag;
|
||||
VM_SAFEPARMCOUNT(6,VM_drawstring);
|
||||
|
||||
string = PRVM_G_STRING(OFS_PARM1);
|
||||
if(!string)
|
||||
{
|
||||
PRVM_G_FLOAT(OFS_RETURN) = -1;
|
||||
VM_Warning("VM_drawstring: %s passed null string !\n",PRVM_NAME);
|
||||
return;
|
||||
}
|
||||
|
||||
pos = PRVM_G_VECTOR(OFS_PARM0);
|
||||
scale = PRVM_G_VECTOR(OFS_PARM2);
|
||||
rgb = PRVM_G_VECTOR(OFS_PARM3);
|
||||
alpha = PRVM_G_FLOAT(OFS_PARM4);
|
||||
flag = (int)PRVM_G_FLOAT(OFS_PARM5);
|
||||
|
||||
SCR_DrawStringExt( pos[0], pos[1], scale[0], scale[1], string, GetRGBA(rgb[0], rgb[1], rgb[2], alpha ), true );
|
||||
PRVM_G_FLOAT(OFS_RETURN) = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_getimagesize
|
||||
|
||||
vector getimagesize(string pic)
|
||||
=========
|
||||
*/
|
||||
void VM_getimagesize(void)
|
||||
{
|
||||
const char *p;
|
||||
int w, h;
|
||||
|
||||
VM_SAFEPARMCOUNT(1, VM_getimagesize);
|
||||
p = PRVM_G_STRING(OFS_PARM0);
|
||||
|
||||
if(!p) PRVM_ERROR("VM_getimagepos: %s passed null picture name !", PRVM_NAME);
|
||||
|
||||
VM_CheckEmptyString(p);
|
||||
re->DrawGetPicSize( &w, &h, (char *)p );
|
||||
|
||||
PRVM_G_VECTOR(OFS_RETURN)[0] = w;
|
||||
PRVM_G_VECTOR(OFS_RETURN)[1] = h;
|
||||
PRVM_G_VECTOR(OFS_RETURN)[2] = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_drawpic
|
||||
|
||||
float drawpic(vector position, string pic, vector size, vector rgb, float alpha, float flag)
|
||||
=========
|
||||
*/
|
||||
void VM_drawpic(void)
|
||||
{
|
||||
const char *picname;
|
||||
float *size, *pos, *rgb, alpha;
|
||||
|
||||
VM_SAFEPARMCOUNT(5, VM_drawpic);
|
||||
picname = PRVM_G_STRING(OFS_PARM1);
|
||||
|
||||
if(!picname)
|
||||
{
|
||||
PRVM_G_FLOAT(OFS_RETURN) = -1;
|
||||
VM_Warning("VM_drawpic: %s passed null picture name !\n", PRVM_NAME);
|
||||
return;
|
||||
}
|
||||
|
||||
VM_CheckEmptyString (picname);
|
||||
|
||||
pos = PRVM_G_VECTOR(OFS_PARM0);
|
||||
size = PRVM_G_VECTOR(OFS_PARM2);
|
||||
rgb = PRVM_G_VECTOR(OFS_PARM3);
|
||||
alpha = PRVM_G_FLOAT(OFS_PARM4);
|
||||
|
||||
re->SetColor( GetRGBA(rgb[0], rgb[1], rgb[2], alpha ));
|
||||
SCR_DrawPic( pos[0], pos[1], size[0], size[1], (char *)picname );
|
||||
re->SetColor( NULL );
|
||||
PRVM_G_FLOAT(OFS_RETURN) = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_drawfill
|
||||
|
||||
float drawfill(vector position, vector size, vector rgb, float alpha, float flag)
|
||||
=========
|
||||
*/
|
||||
void VM_drawfill(void)
|
||||
{
|
||||
float *size, *pos, *rgb, alpha;
|
||||
int flag;
|
||||
|
||||
VM_SAFEPARMCOUNT(5, VM_drawfill);
|
||||
|
||||
pos = PRVM_G_VECTOR(OFS_PARM0);
|
||||
size = PRVM_G_VECTOR(OFS_PARM1);
|
||||
rgb = PRVM_G_VECTOR(OFS_PARM2);
|
||||
alpha = PRVM_G_FLOAT(OFS_PARM3);
|
||||
flag = (int)PRVM_G_FLOAT(OFS_PARM4);
|
||||
|
||||
SCR_FillRect( pos[0], pos[1], size[0], size[1], GetRGBA( rgb[0], rgb[1], rgb[2], alpha ));
|
||||
PRVM_G_FLOAT(OFS_RETURN) = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
|
|
|
@ -445,6 +445,7 @@ const char* com_timestamp( int format )
|
|||
// Build a timestamp that can use for filename (ex: "Nov2006-26 (19.14)");
|
||||
strftime(timestring, sizeof (timestring), "%b%Y-%d (%H.%M)", crt_tm);
|
||||
break;
|
||||
default: return NULL;
|
||||
}
|
||||
|
||||
com_strcpy( timestamp, timestring );
|
||||
|
|
|
@ -161,51 +161,41 @@ type_t *PR_NewType (char *name, int basictype)
|
|||
return &qcc_typeinfo[numtypeinfos-1];
|
||||
}
|
||||
|
||||
void PR_FindBestInclude(char *newfile, char *currentfile, char *rootpath)
|
||||
void PR_FindBestInclude( char *newfile, char *currentfile, char *rootpath )
|
||||
{
|
||||
char fullname[10248];
|
||||
char *stripfrom;
|
||||
int doubledots;
|
||||
char *end = fullname;
|
||||
|
||||
if (!*newfile) return;
|
||||
if( !*newfile ) return;
|
||||
|
||||
doubledots = 0;
|
||||
while(!com.strncmp(newfile, "../", 3) || !com.strncmp(newfile, "..\\", 3))
|
||||
// allow to include ../pathes/
|
||||
currentfile += com.strlen( rootpath ); // could this be bad?
|
||||
|
||||
for( stripfrom = currentfile + com.strlen(currentfile) - 1; stripfrom > currentfile; stripfrom-- )
|
||||
{
|
||||
newfile += 3;
|
||||
doubledots++;
|
||||
}
|
||||
|
||||
currentfile += com.strlen(rootpath); // could this be bad?
|
||||
|
||||
for(stripfrom = currentfile + com.strlen(currentfile) - 1; stripfrom>currentfile; stripfrom--)
|
||||
{
|
||||
if (*stripfrom == '/' || *stripfrom == '\\')
|
||||
if( *stripfrom == '/' || *stripfrom == '\\' )
|
||||
{
|
||||
if (doubledots>0) doubledots--;
|
||||
else
|
||||
{
|
||||
stripfrom++;
|
||||
break;
|
||||
}
|
||||
stripfrom++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
com.strcpy(end, rootpath);
|
||||
com.strcpy( end, rootpath );
|
||||
end = end + com.strlen(end);
|
||||
|
||||
if (*fullname && end[-1] != '/')
|
||||
if(*fullname && end[-1] != '/')
|
||||
{
|
||||
com.strcpy(end, "/");
|
||||
end = end+com.strlen(end);
|
||||
com.strcpy( end, "/" );
|
||||
end = end + com.strlen(end);
|
||||
}
|
||||
|
||||
com.strncpy(end, currentfile, stripfrom - currentfile);
|
||||
com.strncpy( end, currentfile, stripfrom - currentfile );
|
||||
end += stripfrom - currentfile; *end = '\0';
|
||||
com.strcpy(end, newfile);
|
||||
com.strcpy( end, newfile );
|
||||
|
||||
PR_Include(fullname);
|
||||
Msg("include: %s\n", fullname );
|
||||
PR_Include( fullname );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Reference in New Issue