08 Jun 2008
This commit is contained in:
parent
a025e5112f
commit
3242e34c18
|
@ -67,5 +67,5 @@ if exist vprogs\vprogs.plg del /f /q vprogs\vprogs.plg
|
|||
echo Build succeeded!
|
||||
echo Please wait. Xash is now loading
|
||||
cd D:\Xash3D\
|
||||
xash.exe -log -game tmpQuArK -debug -dev 3 +map qctest
|
||||
quake.exe -log -game tmpQuArK -debug -dev 3
|
||||
:done
|
|
@ -0,0 +1,79 @@
|
|||
// base events
|
||||
void Msg( ... ) // send message into console
|
||||
void MsgWarn( ... ) // send warning message into console
|
||||
void Error( ... ) // aborting current level with error message
|
||||
void Exit( void ) // quit from game ( potentially unsafe built-in )
|
||||
string Argv( float num ) // returns parm from server or client command
|
||||
float Argc( void ) // returns num params from server or client command
|
||||
|
||||
// common functions
|
||||
void COM_Trace( float state ) // enable or disable PRVM trace
|
||||
float COM_FileExists( string filename ) // check file for existing
|
||||
float COM_GetFileSize( string filename )// get filesize
|
||||
float COM_GetFileTime( string filename )// get file time
|
||||
float COM_LoadScript( string filename ) // loading script file
|
||||
void COM_ResetScript( void ) // reset script to can parse it again
|
||||
string COM_ReadToken( float newline ) // read next token from scriptfile
|
||||
float COM_FilterToken( string mask, string s, float casecmp ) // filter current token by specified mask
|
||||
string COM_Token( void ) // returns current token
|
||||
float COM_Search( string mask, float casecmp ) // search files by mask
|
||||
void COM_FreeSearch( float handle ) // release current search
|
||||
float COM_SearchNumFiles( float handle )// returns number of find files
|
||||
string COM_SearchFilename( float handle, float num ) // get filename from search list
|
||||
float COM_RandomLong( float min, float max ) // returns random value in specified range
|
||||
float COM_RandomFloat( float min, float max ) // returns random value in specified range
|
||||
void COM_DumpEdict( entity e ) // print info about current edict
|
||||
|
||||
// console variables
|
||||
void Cvar_Register( string name, string value, float flags ) // register new cvar variable
|
||||
void Cvar_SetValue( string name, string value ) // set new cvar value
|
||||
float Cvar_GetValue( string name ) // get cvar value
|
||||
string Cvar_GetString( string name ) // get cvar string
|
||||
|
||||
// filesystem ( uses Xash Virtual filesystem )
|
||||
float fopen( string filename, float mode ) // open file for read or write
|
||||
void fclose( float fhandle ) // close current file
|
||||
string fgets( float fhandle ) // get string from file
|
||||
entity fgete( float fhandle ) // get entity from file // same as parse edict
|
||||
void fputs( float fhandle, string s ) // put string into file
|
||||
void fpute( float fhandle, entity e ) // put entity into file
|
||||
|
||||
// mathlib
|
||||
float min(float a, float b )
|
||||
float max(float a, float b )
|
||||
float bound(float min, float val, float max)
|
||||
float pow (float x, float y)
|
||||
float sin (float f)
|
||||
float cos (float f)
|
||||
float tan (float f)
|
||||
float sqrt (float f)
|
||||
float rint (float v)
|
||||
float floor(float v)
|
||||
float ceil (float v)
|
||||
float fabs (float f)
|
||||
float fmod (float f)
|
||||
|
||||
// veclib
|
||||
vector normalize(vector v)
|
||||
float veclength(vector v)
|
||||
float vectoyaw(vector v)
|
||||
vector vectoangles(vector v)
|
||||
vector randomvec( void )
|
||||
void vectorvectors(vector dir)
|
||||
void makevectors(vector dir)
|
||||
void makevectors2(vector dir)
|
||||
|
||||
// entity operations (with compiler support don't rename them)
|
||||
entity spawn( void )
|
||||
void remove( entity e )
|
||||
entity nextent( entity e )
|
||||
|
||||
// stdlib
|
||||
float atof(string s) // all other conversion VMach can make automatically
|
||||
string ftoa(float f)
|
||||
string vtoa(vector v)
|
||||
vector atov(string s)
|
||||
float strlen(string s) // returns string length
|
||||
string strcat(string s1, string s2) // put one string at end of another
|
||||
string va( format, ... ) // var_args format
|
||||
string timestamp( float fmt ) // returns timestamp
|
|
@ -184,7 +184,7 @@ 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_ConPrintf, // #45 void Msg( ... )
|
||||
VM_wprint, // #46 void MsgWarn( ... )
|
||||
VM_objerror, // #47 void Error( ... )
|
||||
VM_bprint, // #48 void bprint(string s)
|
||||
|
@ -215,6 +215,7 @@ 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
|
||||
};
|
||||
|
||||
const int vm_cl_numbuiltins = sizeof(vm_cl_builtins) / sizeof(prvm_builtin_t); //num of builtins
|
||||
|
|
541
engine/common.c
541
engine/common.c
|
@ -1,27 +1,528 @@
|
|||
/*
|
||||
Copyright (C) 1997-2001 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
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with 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
|
||||
//=======================================================================
|
||||
// Copyright XashXT Group 2008 ©
|
||||
// common.c - misc functions used in client and server
|
||||
//=======================================================================
|
||||
|
||||
#include "engine.h"
|
||||
#include "basefiles.h"
|
||||
|
||||
/*
|
||||
=======================================================================
|
||||
|
||||
VIRTUAL MACHINE COMMON UTILS
|
||||
=======================================================================
|
||||
*/
|
||||
bool VM_ValidateArgs( const char *builtin, int num_argc )
|
||||
{
|
||||
if( prog->argc < num_argc )
|
||||
{
|
||||
MsgDev( D_ERROR, "%s called with too few parameters\n", builtin );
|
||||
return false;
|
||||
}
|
||||
else if( prog->argc < num_argc )
|
||||
{
|
||||
MsgDev( D_ERROR, "%s called with too many parameters\n", builtin );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_VarArgs
|
||||
|
||||
supports follow prefixes:
|
||||
%d - integer or bool (declared as float)
|
||||
%i - integer or bool (declared as float)
|
||||
%f - float
|
||||
%g - formatted float with cutoff zeroes
|
||||
%s - string
|
||||
%p - function pointer (will be printed function name)
|
||||
%e - entity (will be print entity number) - just in case
|
||||
%v - vector (format: %g %g %g)
|
||||
=========
|
||||
*/
|
||||
const char *VM_VarArgs( int start_arg )
|
||||
{
|
||||
static char vm_string[MAX_STRING_CHARS];
|
||||
int arg = start_arg + 1;// skip format string
|
||||
char *out, *outend;
|
||||
static string vm_arg;
|
||||
const char *s, *m;
|
||||
mfunction_t *func;
|
||||
float *vec;
|
||||
|
||||
// get the format string
|
||||
s = PRVM_G_STRING((OFS_PARM0 + start_arg * 3));
|
||||
out = vm_string;
|
||||
outend = out + 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
|
||||
|
||||
switch((int)s[1])
|
||||
{
|
||||
case 'd': com.snprintf( vm_arg, MAX_STRING, "%d", (int)PRVM_G_FLOAT(OFS_PARM0+arg*3)); break;
|
||||
case 'i': com.snprintf( vm_arg, MAX_STRING, "%i", (int)PRVM_G_FLOAT(OFS_PARM0+arg*3)); break;
|
||||
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 '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
|
||||
else com.snprintf( vm_arg, MAX_STRING, "%s", PRVM_GetString(func->s_name));
|
||||
break;
|
||||
case 'v': // vector
|
||||
vec = PRVM_G_VECTOR((OFS_PARM0+arg*3));
|
||||
com.snprintf( vm_arg, MAX_STRING, "%g %g %g", vec[0], vec[1], vec[2] );
|
||||
break;
|
||||
default:
|
||||
arg++; // skip invalid arg
|
||||
continue;
|
||||
}
|
||||
|
||||
s += 2;
|
||||
m = vm_arg, arg++;
|
||||
while( out < outend && *m )
|
||||
*out++ = *m++; // copy next arg
|
||||
}
|
||||
|
||||
return vm_string;
|
||||
}
|
||||
|
||||
/*
|
||||
=======================================================================
|
||||
|
||||
VIRTUAL MACHINE GENERIC API
|
||||
=======================================================================
|
||||
*/
|
||||
/*
|
||||
=========
|
||||
VM_ConPrintf
|
||||
|
||||
void Con_Printf( ... )
|
||||
=========
|
||||
*/
|
||||
void VM_ConPrintf( void )
|
||||
{
|
||||
com.print(VM_VarArgs( 0 ));
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_ConDPrintf
|
||||
|
||||
void Con_DPrintf( float level, ... )
|
||||
=========
|
||||
*/
|
||||
void VM_ConDPrintf( void )
|
||||
{
|
||||
if(host.developer < (int)PRVM_G_FLOAT(OFS_PARM0))
|
||||
return;
|
||||
com.print(VM_VarArgs( 1 ));
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_HostError
|
||||
|
||||
void Com_Error( ... )
|
||||
=========
|
||||
*/
|
||||
void VM_HostError( void )
|
||||
{
|
||||
Host_Error(VM_VarArgs( 0 ));
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_SysExit
|
||||
|
||||
void Sys_Exit( void )
|
||||
=========
|
||||
*/
|
||||
void VM_SysExit( void )
|
||||
{
|
||||
if(!VM_ValidateArgs( "Sys_Exit", 0 ))
|
||||
return;
|
||||
|
||||
// using only for debugging :)
|
||||
if( host.developer ) com.exit();
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_CmdArgv
|
||||
|
||||
string Cmd_Argv( float arg )
|
||||
=========
|
||||
*/
|
||||
void VM_CmdArgv( void )
|
||||
{
|
||||
int arg;
|
||||
|
||||
if(!VM_ValidateArgs( "Cmd_Argv", 1 ))
|
||||
return;
|
||||
|
||||
arg = (int)PRVM_G_FLOAT(OFS_PARM0);
|
||||
if( arg >= 0 && arg < Cmd_Argc())
|
||||
PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString(Cmd_Argv( arg ));
|
||||
else PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString( NULL );
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_CmdArgc
|
||||
|
||||
float Cmd_Argc( void )
|
||||
=========
|
||||
*/
|
||||
void VM_CmdArgc( void )
|
||||
{
|
||||
if(!VM_ValidateArgs( "Cmd_Argc", 0 ))
|
||||
return;
|
||||
|
||||
PRVM_G_FLOAT(OFS_RETURN) = Cmd_Argc();
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_ComTrace
|
||||
|
||||
void Com_Trace( float enable )
|
||||
=========
|
||||
*/
|
||||
void VM_ComTrace( void )
|
||||
{
|
||||
if(!VM_ValidateArgs( "Com_Trace", 1 ))
|
||||
return;
|
||||
|
||||
if(PRVM_G_FLOAT(OFS_PARM0))
|
||||
prog->trace = true;
|
||||
else prog->trace = false;
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_ComFileExists
|
||||
|
||||
float Com_FileExists( string filename )
|
||||
=========
|
||||
*/
|
||||
void VM_ComFileExists( void )
|
||||
{
|
||||
if(!VM_ValidateArgs( "Com_FileExists", 1 ))
|
||||
return;
|
||||
|
||||
PRVM_G_FLOAT(OFS_RETURN) = FS_FileExists(PRVM_G_STRING(OFS_PARM0)) ? 1.0f : 0.0f;
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_ComFileSize
|
||||
|
||||
float Com_FileSize( string filename )
|
||||
=========
|
||||
*/
|
||||
void VM_ComFileSize( void )
|
||||
{
|
||||
if(!VM_ValidateArgs( "Com_FileSize", 1 ))
|
||||
return;
|
||||
|
||||
PRVM_G_FLOAT(OFS_RETURN) = (float)FS_FileSize(PRVM_G_STRING(OFS_PARM0));
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_ComFileTime
|
||||
|
||||
float Com_FileTime( string filename )
|
||||
=========
|
||||
*/
|
||||
void VM_ComFileTime( void )
|
||||
{
|
||||
if(!VM_ValidateArgs( "Com_FileTime", 1 ))
|
||||
return;
|
||||
|
||||
PRVM_G_FLOAT(OFS_RETURN) = (float)FS_FileTime(PRVM_G_STRING(OFS_PARM0));
|
||||
}
|
||||
|
||||
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_ComAtof( void )
|
||||
{
|
||||
}
|
||||
|
||||
void VM_ComFtoa( void )
|
||||
{
|
||||
}
|
||||
|
||||
void VM_ComAtov( void )
|
||||
{
|
||||
}
|
||||
|
||||
void VM_ComVtoa( void )
|
||||
{
|
||||
}
|
||||
|
||||
void VM_ComStrlen( void )
|
||||
{
|
||||
}
|
||||
|
||||
void VM_TimeStamp( void )
|
||||
{
|
||||
}
|
||||
|
||||
void VM_SpawnEdict( void )
|
||||
{
|
||||
}
|
||||
|
||||
void VM_RemoveEdict( void )
|
||||
{
|
||||
}
|
||||
|
||||
void VM_NextEdict( void )
|
||||
{
|
||||
}
|
||||
|
||||
void VM_FS_Open( void )
|
||||
{
|
||||
}
|
||||
|
||||
void VM_FS_Gets( void )
|
||||
{
|
||||
}
|
||||
|
||||
void VM_FS_Gete( void )
|
||||
{
|
||||
}
|
||||
|
||||
void VM_FS_Puts( void )
|
||||
{
|
||||
}
|
||||
|
||||
void VM_FS_Pute( void )
|
||||
{
|
||||
}
|
||||
|
||||
void VM_FS_Close( void )
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_sin
|
||||
|
||||
float sin(float)
|
||||
=========
|
||||
*/
|
||||
void VM_sin (void)
|
||||
{
|
||||
VM_SAFEPARMCOUNT(1,VM_sin);
|
||||
PRVM_G_FLOAT(OFS_RETURN) = sin(PRVM_G_FLOAT(OFS_PARM0));
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_cos
|
||||
float cos(float)
|
||||
=========
|
||||
*/
|
||||
void VM_cos (void)
|
||||
{
|
||||
VM_SAFEPARMCOUNT(1,VM_cos);
|
||||
PRVM_G_FLOAT(OFS_RETURN) = cos(PRVM_G_FLOAT(OFS_PARM0));
|
||||
}
|
||||
|
||||
void VM_tan (void)
|
||||
{
|
||||
}
|
||||
|
||||
void VM_asin (void)
|
||||
{
|
||||
}
|
||||
|
||||
void VM_acos (void)
|
||||
{
|
||||
}
|
||||
|
||||
void VM_atan (void)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_sqrt
|
||||
|
||||
float sqrt(float)
|
||||
=========
|
||||
*/
|
||||
void VM_sqrt (void)
|
||||
{
|
||||
VM_SAFEPARMCOUNT(1,VM_sqrt);
|
||||
PRVM_G_FLOAT(OFS_RETURN) = sqrt(PRVM_G_FLOAT(OFS_PARM0));
|
||||
}
|
||||
|
||||
void VM_VectorLength( void )
|
||||
{
|
||||
}
|
||||
|
||||
void VM_VectorNormalize( void )
|
||||
{
|
||||
}
|
||||
|
||||
prvm_builtin_t std_builtins[] =
|
||||
{
|
||||
NULL, // #0 (leave blank as default, but can include easter egg )
|
||||
|
||||
// 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 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_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 )
|
||||
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 )
|
||||
NULL, // #44 -- reserved --
|
||||
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, // #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_VectorNormalize, // #76 vector VectorNormalize( vector v )
|
||||
VM_VectorLength, // #77 float VectorLength( vector v )
|
||||
NULL, // #78 -- reserved --
|
||||
NULL, // #79 -- reserved --
|
||||
NULL, // #80 -- reserved --
|
||||
e10, e10 // #81 - #100 are reserved for future expansions
|
||||
};
|
||||
|
||||
/*
|
||||
=======================================================================
|
||||
|
||||
|
|
|
@ -233,12 +233,18 @@ _inline edict_t *PRVM_EDICT_NUM( int n )
|
|||
#define PRVM_ED_FindGlobal vm->FindGlobal
|
||||
#define PRVM_ED_FindFunction vm->FindFunction
|
||||
|
||||
// helper common functions
|
||||
const char *VM_VarArgs( int start_arg );
|
||||
bool VM_ValidateArgs( const char *builtin, int num_argc );
|
||||
|
||||
// builtins and other general functions
|
||||
void VM_ConPrintf( void );
|
||||
|
||||
char *VM_GetTempString(void);
|
||||
void VM_CheckEmptyString (const char *s);
|
||||
void VM_VarString(int first, char *out, int outlength);
|
||||
|
||||
|
||||
void VM_checkextension (void);
|
||||
void VM_error (void);
|
||||
void VM_objerror (void);
|
||||
|
|
Binary file not shown.
|
@ -1203,44 +1203,6 @@ void VM_changelevel (void)
|
|||
Cbuf_AddText (va("changelevel %s\n",s));
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_sin
|
||||
|
||||
float sin(float)
|
||||
=========
|
||||
*/
|
||||
void VM_sin (void)
|
||||
{
|
||||
VM_SAFEPARMCOUNT(1,VM_sin);
|
||||
PRVM_G_FLOAT(OFS_RETURN) = sin(PRVM_G_FLOAT(OFS_PARM0));
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_cos
|
||||
float cos(float)
|
||||
=========
|
||||
*/
|
||||
void VM_cos (void)
|
||||
{
|
||||
VM_SAFEPARMCOUNT(1,VM_cos);
|
||||
PRVM_G_FLOAT(OFS_RETURN) = cos(PRVM_G_FLOAT(OFS_PARM0));
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_sqrt
|
||||
|
||||
float sqrt(float)
|
||||
=========
|
||||
*/
|
||||
void VM_sqrt (void)
|
||||
{
|
||||
VM_SAFEPARMCOUNT(1,VM_sqrt);
|
||||
PRVM_G_FLOAT(OFS_RETURN) = sqrt(PRVM_G_FLOAT(OFS_PARM0));
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
VM_randomvec
|
||||
|
|
|
@ -2713,6 +2713,22 @@ fs_offset_t FS_FileSize (const char *filename)
|
|||
return length;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
FS_FileTime
|
||||
|
||||
return time of creation file in seconds
|
||||
==================
|
||||
*/
|
||||
fs_offset_t FS_FileTime (const char *filename)
|
||||
{
|
||||
struct stat buf;
|
||||
|
||||
if( stat( filename, &buf) == -1 )
|
||||
return -1;
|
||||
|
||||
return buf.st_mtime;
|
||||
}
|
||||
|
||||
/*
|
||||
===========
|
||||
|
|
|
@ -636,7 +636,7 @@ char *va(const char *format, ...)
|
|||
s = string[stringindex];
|
||||
stringindex = (stringindex + 1) & 7;
|
||||
va_start (argptr, format);
|
||||
com_vsnprintf (s, sizeof (string[0]), format, argptr);
|
||||
com_vsnprintf (s, sizeof(string[0]), format, argptr);
|
||||
va_end (argptr);
|
||||
return s;
|
||||
}
|
|
@ -76,6 +76,7 @@ void Sys_GetStdAPI( void )
|
|||
com.Com_FileBase = FS_FileBase; // get filename without path & ext
|
||||
com.Com_FileExists = FS_FileExists; // return true if file exist
|
||||
com.Com_FileSize = FS_FileSize; // same as Com_FileExists but return filesize
|
||||
com.Com_FileTime = FS_FileTime; // same as Com_FileExists but return filetime
|
||||
com.Com_FileExtension = FS_FileExtension; // return extension of file
|
||||
com.Com_RemovePath = FS_FileWithoutPath; // return file without path
|
||||
com.Com_StripExtension = FS_StripExtension; // remove extension if present
|
||||
|
|
|
@ -272,6 +272,7 @@ int FS_Seek (file_t* file, fs_offset_t offset, int whence);
|
|||
int FS_Gets (file_t* file, byte *string, size_t bufsize );
|
||||
int FS_Printf(file_t* file, const char* format, ...);
|
||||
fs_offset_t FS_FileSize (const char *filename);
|
||||
fs_offset_t FS_FileTime (const char *filename);
|
||||
int FS_Print(file_t* file, const char *msg);
|
||||
bool FS_FileExists (const char *filename);
|
||||
int FS_UnGetc (file_t* file, byte c);
|
||||
|
|
|
@ -368,6 +368,7 @@ typedef enum
|
|||
ev_variant,
|
||||
ev_struct,
|
||||
ev_union,
|
||||
ev_bool,
|
||||
} etype_t;
|
||||
|
||||
typedef struct statement16_s
|
||||
|
|
|
@ -69,6 +69,7 @@ typedef struct stdilib_api_s
|
|||
void (*Com_FileBase)(const char *in, char *out); // get filename without path & ext
|
||||
bool (*Com_FileExists)(const char *filename); // return true if file exist
|
||||
long (*Com_FileSize)(const char *filename); // same as Com_FileExists but return filesize
|
||||
long (*Com_FileTime)(const char *filename); // same as Com_FileExists but return filetime
|
||||
const char *(*Com_FileExtension)(const char *in); // return extension of file
|
||||
const char *(*Com_RemovePath)(const char *in); // return file without path
|
||||
void (*Com_StripExtension)(char *path); // remove extension if present
|
||||
|
@ -256,6 +257,8 @@ filesystem manager
|
|||
#define FS_DefaultExtension com.Com_DefaultExtension
|
||||
#define FS_FileExtension( ext ) com.Com_FileExtension( ext )
|
||||
#define FS_FileExists( file ) com.Com_FileExists( file )
|
||||
#define FS_FileSize( file ) com.Com_FileSize( file )
|
||||
#define FS_FileTime( file ) com.Com_FileTime( file )
|
||||
#define FS_Close( file ) com.fclose( file )
|
||||
#define FS_FileBase( x, y ) com.Com_FileBase( x, y )
|
||||
#define FS_Printf com.fprintf
|
||||
|
|
|
@ -67,5 +67,5 @@ if exist vprogs\vprogs.plg del /f /q vprogs\vprogs.plg
|
|||
echo Build succeeded!
|
||||
echo Please wait. Xash is now loading
|
||||
cd D:\Xash3D\
|
||||
xash.exe -game tmpQuArK +map walk_test -dev 3 -debug -log
|
||||
quake.exe -game tmpQuArK -dev 3 -debug -log
|
||||
:done
|
2
todo.log
2
todo.log
|
@ -10,6 +10,8 @@ SprExplorer
|
|||
fopen завешивает приложение, при попытке создать файл в несуществующей директории. Ну вылетал бы чтоли, или ошибку
|
||||
возвращал.
|
||||
|
||||
0. Создать универсальный shared interface для всех виртуальных машин
|
||||
|
||||
Текущие задачи:
|
||||
Полная переделка меню, дабы не возвращаться к этому вопросу в дальнейшем (имплементация базового меню)
|
||||
1. Вырезать нахрен меню от quake2
|
||||
|
|
|
@ -66,7 +66,8 @@ char *basictypenames[] =
|
|||
"pointer",
|
||||
"integer",
|
||||
"struct",
|
||||
"union"
|
||||
"union",
|
||||
"bool",
|
||||
};
|
||||
|
||||
//========================================
|
||||
|
@ -370,6 +371,7 @@ keyword_t pr_keywords[] =
|
|||
{6, KEYWORD_VAR, "var", "", 0 },
|
||||
{7, KEYWORD_UNION, "union", "", 0 },
|
||||
{7, KEYWORD_THINKTIME, "thinktime", "", 0 },
|
||||
{8, KEYWORD_BOOL, "bool", "BOOL", 0 },
|
||||
{8, KEYWORD_ASM, "asm", "_asm", 0 },
|
||||
{8, KEYWORD_SHARED, "shared", "_export",0 }, // multiprogs stuff
|
||||
{8, KEYWORD_NOSAVE, "nosave", "", 0 },
|
||||
|
@ -3073,7 +3075,7 @@ def_t *PR_Term( void )
|
|||
if (PR_CheckToken ("("))
|
||||
{
|
||||
// float is always enabled
|
||||
if (PR_CheckToken("float")) // check for type casts
|
||||
if (PR_CheckForKeyword( KEYWORD_FLOAT )) // check for type casts
|
||||
{
|
||||
PR_Expect (")");
|
||||
e = PR_Term();
|
||||
|
|
|
@ -368,6 +368,12 @@ char *PRVM_ValueString (etype_t type, prvm_eval_t *val)
|
|||
|
||||
switch (type)
|
||||
{
|
||||
case ev_struct:
|
||||
com.strncpy ( line, "struct", sizeof (line));
|
||||
break;
|
||||
case ev_union:
|
||||
com.strncpy ( line, "union", sizeof (line));
|
||||
break;
|
||||
case ev_string:
|
||||
com.strncpy (line, PRVM_GetString (val->string), sizeof (line));
|
||||
break;
|
||||
|
@ -375,8 +381,7 @@ char *PRVM_ValueString (etype_t type, prvm_eval_t *val)
|
|||
n = val->edict;
|
||||
if (n < 0 || n >= vm.prog->limit_edicts)
|
||||
com.sprintf (line, "entity %i (invalid!)", n);
|
||||
else
|
||||
com.sprintf (line, "entity %i", n);
|
||||
else com.sprintf (line, "entity %i", n);
|
||||
break;
|
||||
case ev_function:
|
||||
f = vm.prog->functions + val->function;
|
||||
|
@ -384,17 +389,19 @@ char *PRVM_ValueString (etype_t type, prvm_eval_t *val)
|
|||
break;
|
||||
case ev_field:
|
||||
def = PRVM_ED_FieldAtOfs ( val->_int );
|
||||
com.sprintf (line, ".%s", PRVM_GetString(def->s_name));
|
||||
if(!def) com.sprintf (line, ".???", val->_int );
|
||||
else com.sprintf (line, ".%s", PRVM_GetString(def->s_name));
|
||||
break;
|
||||
case ev_void:
|
||||
com.sprintf (line, "void");
|
||||
break;
|
||||
case ev_float:
|
||||
// LordHavoc: changed from %5.1f to %10.4f
|
||||
com.sprintf (line, "%10.4f", val->_float);
|
||||
break;
|
||||
case ev_integer:
|
||||
com.sprintf (line, "%i", val->_int);
|
||||
break;
|
||||
case ev_vector:
|
||||
// LordHavoc: changed from %5.1f to %10.4f
|
||||
com.sprintf (line, "'%10.4f %10.4f %10.4f'", val->vector[0], val->vector[1], val->vector[2]);
|
||||
break;
|
||||
case ev_pointer:
|
||||
|
@ -471,8 +478,10 @@ char *PRVM_UglyValueString (etype_t type, prvm_eval_t *val)
|
|||
case ev_vector:
|
||||
com.sprintf (line, "%f %f %f", val->vector[0], val->vector[1], val->vector[2]);
|
||||
break;
|
||||
case ev_pointer:
|
||||
case ev_integer:
|
||||
com.sprintf (line, "%i", val->_int);
|
||||
break;
|
||||
case ev_pointer:
|
||||
case ev_variant:
|
||||
case ev_struct:
|
||||
case ev_union:
|
||||
|
|
|
@ -95,7 +95,7 @@ enum {
|
|||
KEYWORD_IF,
|
||||
KEYWORD_VOID,
|
||||
KEYWORD_ELSE,
|
||||
KEYWORD_LOCAL, // legacy
|
||||
KEYWORD_LOCAL, // legacy ( not used )
|
||||
KEYWORD_WHILE,
|
||||
KEYWORD_ENTITY,
|
||||
KEYWORD_FLOAT,
|
||||
|
@ -127,6 +127,7 @@ enum {
|
|||
KEYWORD_THINKTIME,
|
||||
|
||||
// progs 8 keywords
|
||||
KEYWORD_BOOL,
|
||||
KEYWORD_ASM,
|
||||
|
||||
KEYWORD_SHARED,
|
||||
|
|
Reference in New Issue