#include "cl_collision.h"
#include "clvm_cmds.h"
#include "ft2.h"
+#include "mdfour.h"
extern cvar_t prvm_backtraceforwarnings;
return false;
#endif
}
+
+ // special sheck for d0_blind_id
+ if (!strcasecmp("DP_CRYPTO", name))
+ return Crypto_Available();
+ if (!strcasecmp("DP_QC_DIGEST_SHA256", name))
+ return Crypto_Available();
+
return true;
}
}
}
entnum = ((pnum == PRVM_CLIENTPROG) ? MAX_EDICTS : 0) + PRVM_NUM_FOR_EDICT(PRVM_G_EDICT(OFS_PARM0));
entchannel = (int)PRVM_G_FLOAT(OFS_PARM1);
- if (entchannel <= 0 || entchannel > 8)
+ entchannel = CHAN_USER2ENGINE(entchannel);
+ if (!IS_CHAN(entchannel))
VM_Warning("VM_getsoundtime: %s: bad channel %i\n", PRVM_NAME, entchannel);
PRVM_G_FLOAT(OFS_RETURN) = (float)S_GetEntChannelPosition(entnum, entchannel);
}
=========
VM_drawstring
-float drawstring(vector position, string text, vector scale, vector rgb, float alpha, float flag)
+float drawstring(vector position, string text, vector scale, vector rgb, float alpha[, float flag])
=========
*/
void VM_drawstring(void)
{
float *pos,*scale,*rgb;
const char *string;
- int flag;
+ int flag = 0;
float sx, sy;
- VM_SAFEPARMCOUNT(6,VM_drawstring);
+ VM_SAFEPARMCOUNTRANGE(5,6,VM_drawstring);
string = PRVM_G_STRING(OFS_PARM1);
pos = PRVM_G_VECTOR(OFS_PARM0);
scale = PRVM_G_VECTOR(OFS_PARM2);
rgb = PRVM_G_VECTOR(OFS_PARM3);
- flag = (int)PRVM_G_FLOAT(OFS_PARM5);
+ if (prog->argc >= 6)
+ flag = (int)PRVM_G_FLOAT(OFS_PARM5);
if(flag < DRAWFLAG_NORMAL || flag >=DRAWFLAG_NUMFLAGS)
{
{
const char *picname;
float *size, *pos, *rgb;
- int flag;
+ int flag = 0;
- VM_SAFEPARMCOUNT(6,VM_drawpic);
+ VM_SAFEPARMCOUNTRANGE(5,6,VM_drawpic);
picname = PRVM_G_STRING(OFS_PARM1);
VM_CheckEmptyString (picname);
pos = PRVM_G_VECTOR(OFS_PARM0);
size = PRVM_G_VECTOR(OFS_PARM2);
rgb = PRVM_G_VECTOR(OFS_PARM3);
- flag = (int) PRVM_G_FLOAT(OFS_PARM5);
+ if (prog->argc >= 6)
+ flag = (int) PRVM_G_FLOAT(OFS_PARM5);
if(flag < DRAWFLAG_NORMAL || flag >=DRAWFLAG_NUMFLAGS)
{
========================
*/
void VM_Gecko_Init( void ) {
- // the prog struct is memset to 0 by Initprog? [12/6/2007 Black]
- // FIXME: remove the other _Init functions then, too? [12/6/2007 Black]
+ // REMOVED
}
/*
========================
*/
void VM_Gecko_Destroy( void ) {
- int i;
- for( i = 0 ; i < PRVM_MAX_GECKOINSTANCES ; i++ ) {
- clgecko_t **instance = &prog->opengeckoinstances[ i ];
- if( *instance ) {
- CL_Gecko_DestroyBrowser( *instance );
- }
- *instance = NULL;
- }
+ // REMOVED
}
/*
========================
*/
void VM_gecko_create( void ) {
- const char *name;
- int i;
- clgecko_t *instance;
-
- VM_SAFEPARMCOUNT( 1, VM_gecko_create );
-
- name = PRVM_G_STRING( OFS_PARM0 );
- VM_CheckEmptyString( name );
-
- // find an empty slot for this gecko browser..
- for( i = 0 ; i < PRVM_MAX_GECKOINSTANCES ; i++ ) {
- if( prog->opengeckoinstances[ i ] == NULL ) {
- break;
- }
- }
- if( i == PRVM_MAX_GECKOINSTANCES ) {
- VM_Warning("VM_gecko_create: %s ran out of gecko handles (%i)\n", PRVM_NAME, PRVM_MAX_GECKOINSTANCES);
- PRVM_G_FLOAT( OFS_RETURN ) = 0;
- return;
- }
-
- instance = prog->opengeckoinstances[ i ] = CL_Gecko_CreateBrowser( name, PRVM_GetProgNr() );
- if( !instance ) {
- // TODO: error handling [12/3/2007 Black]
- PRVM_G_FLOAT( OFS_RETURN ) = 0;
- return;
- }
- PRVM_G_FLOAT( OFS_RETURN ) = 1;
+ // REMOVED
+ PRVM_G_FLOAT( OFS_RETURN ) = 0;
}
/*
========================
*/
void VM_gecko_destroy( void ) {
- const char *name;
- clgecko_t *instance;
-
- VM_SAFEPARMCOUNT( 1, VM_gecko_destroy );
-
- name = PRVM_G_STRING( OFS_PARM0 );
- VM_CheckEmptyString( name );
- instance = CL_Gecko_FindBrowser( name );
- if( !instance ) {
- return;
- }
- CL_Gecko_DestroyBrowser( instance );
+ // REMOVED
}
/*
========================
*/
void VM_gecko_navigate( void ) {
- const char *name;
- const char *URI;
- clgecko_t *instance;
-
- VM_SAFEPARMCOUNT( 2, VM_gecko_navigate );
-
- name = PRVM_G_STRING( OFS_PARM0 );
- URI = PRVM_G_STRING( OFS_PARM1 );
- VM_CheckEmptyString( name );
- VM_CheckEmptyString( URI );
-
- instance = CL_Gecko_FindBrowser( name );
- if( !instance ) {
- return;
- }
- CL_Gecko_NavigateToURI( instance, URI );
+ // REMOVED
}
/*
========================
*/
void VM_gecko_keyevent( void ) {
- const char *name;
- unsigned int key;
- clgecko_buttoneventtype_t eventtype;
- clgecko_t *instance;
-
- VM_SAFEPARMCOUNT( 3, VM_gecko_keyevent );
-
- name = PRVM_G_STRING( OFS_PARM0 );
- VM_CheckEmptyString( name );
- key = (unsigned int) PRVM_G_FLOAT( OFS_PARM1 );
- switch( (unsigned int) PRVM_G_FLOAT( OFS_PARM2 ) ) {
- case 0:
- eventtype = CLG_BET_DOWN;
- break;
- case 1:
- eventtype = CLG_BET_UP;
- break;
- case 2:
- eventtype = CLG_BET_PRESS;
- break;
- case 3:
- eventtype = CLG_BET_DOUBLECLICK;
- break;
- default:
- // TODO: console printf? [12/3/2007 Black]
- PRVM_G_FLOAT( OFS_RETURN ) = 0;
- return;
- }
-
- instance = CL_Gecko_FindBrowser( name );
- if( !instance ) {
- PRVM_G_FLOAT( OFS_RETURN ) = 0;
- return;
- }
-
- PRVM_G_FLOAT( OFS_RETURN ) = (CL_Gecko_Event_Key( instance, (keynum_t) key, eventtype ) == true);
+ // REMOVED
+ PRVM_G_FLOAT( OFS_RETURN ) = 0;
}
/*
========================
*/
void VM_gecko_movemouse( void ) {
- const char *name;
- float x, y;
- clgecko_t *instance;
-
- VM_SAFEPARMCOUNT( 3, VM_gecko_movemouse );
-
- name = PRVM_G_STRING( OFS_PARM0 );
- VM_CheckEmptyString( name );
- x = PRVM_G_FLOAT( OFS_PARM1 );
- y = PRVM_G_FLOAT( OFS_PARM2 );
-
- instance = CL_Gecko_FindBrowser( name );
- if( !instance ) {
- return;
- }
- CL_Gecko_Event_CursorMove( instance, x, y );
+ // REMOVED
}
========================
*/
void VM_gecko_resize( void ) {
- const char *name;
- float w, h;
- clgecko_t *instance;
-
- VM_SAFEPARMCOUNT( 3, VM_gecko_movemouse );
-
- name = PRVM_G_STRING( OFS_PARM0 );
- VM_CheckEmptyString( name );
- w = PRVM_G_FLOAT( OFS_PARM1 );
- h = PRVM_G_FLOAT( OFS_PARM2 );
-
- instance = CL_Gecko_FindBrowser( name );
- if( !instance ) {
- return;
- }
- CL_Gecko_Resize( instance, (int) w, (int) h );
+ // REMOVED
}
========================
*/
void VM_gecko_get_texture_extent( void ) {
- const char *name;
- clgecko_t *instance;
-
- VM_SAFEPARMCOUNT( 1, VM_gecko_movemouse );
-
- name = PRVM_G_STRING( OFS_PARM0 );
- VM_CheckEmptyString( name );
-
- PRVM_G_VECTOR(OFS_RETURN)[2] = 0;
- instance = CL_Gecko_FindBrowser( name );
- if( !instance ) {
- PRVM_G_VECTOR(OFS_RETURN)[0] = 0;
- PRVM_G_VECTOR(OFS_RETURN)[1] = 0;
- return;
- }
- CL_Gecko_GetTextureExtent( instance,
- PRVM_G_VECTOR(OFS_RETURN), PRVM_G_VECTOR(OFS_RETURN)+1 );
+ // REMOVED
+ PRVM_G_VECTOR(OFS_RETURN)[0] = 0;
+ PRVM_G_VECTOR(OFS_RETURN)[1] = 0;
}
{
float insensitive;
static char s[VM_STRINGTEMP_LENGTH];
- VM_SAFEPARMCOUNTRANGE(2, 8, VM_hash);
+ VM_SAFEPARMCOUNTRANGE(2, 8, VM_crc16);
insensitive = PRVM_G_FLOAT(OFS_PARM0);
VM_VarString(1, s, sizeof(s));
PRVM_G_FLOAT(OFS_RETURN) = (unsigned short) ((insensitive ? CRC_Block_CaseInsensitive : CRC_Block) ((unsigned char *) s, strlen(s)));
}
+// #639 float(string digest, string data, ...) digest_hex
+void VM_digest_hex(void)
+{
+ const char *digest;
+
+ static char out[32];
+ static char outhex[65];
+ int outlen;
+
+ static char s[VM_STRINGTEMP_LENGTH];
+ int len;
+
+ VM_SAFEPARMCOUNTRANGE(2, 8, VM_digest_hex);
+ digest = PRVM_G_STRING(OFS_PARM0);
+ if(!digest)
+ digest = "";
+ VM_VarString(1, s, sizeof(s));
+ len = strlen(s);
+
+ outlen = 0;
+
+ if(!strcmp(digest, "MD4"))
+ {
+ outlen = 16;
+ mdfour((unsigned char *) out, (unsigned char *) s, len);
+ }
+ else if(!strcmp(digest, "SHA256") && Crypto_Available())
+ {
+ outlen = 32;
+ sha256((unsigned char *) out, (unsigned char *) s, len);
+ }
+ // no warning needed on mismatch - we return string_null to QC
+
+ if(outlen)
+ {
+ int i;
+ static const char *hexmap = "0123456789abcdef";
+ for(i = 0; i < outlen; ++i)
+ {
+ outhex[2*i] = hexmap[(out[i] >> 4) & 15];
+ outhex[2*i+1] = hexmap[(out[i] >> 0) & 15];
+ }
+ outhex[2*i] = 0;
+ PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(outhex);
+ }
+ else
+ PRVM_G_INT(OFS_RETURN) = 0;
+}
+
void VM_wasfreed (void)
{
VM_SAFEPARMCOUNT(1, VM_wasfreed);
// only init the stuff for the current prog
VM_Files_Init();
VM_Search_Init();
- VM_Gecko_Init();
// VM_BufStr_Init();
}
CL_PurgeOwner( MENUOWNER );
VM_Search_Reset();
VM_Files_CloseAll();
- VM_Gecko_Destroy();
// VM_BufStr_ShutDown();
}
handle->prognr = PRVM_GetProgNr();
handle->starttime = prog->starttime;
handle->id = id;
- if(postseparator)
+ if(postseparator && posttype && *posttype)
{
size_t l = strlen(postseparator);
if(poststringbuffer >= 0)