float itof(intt ent)
intt ftoi(float num)
+
+float altstr_count(string)
+string altstr_prepare(string)
+string altstr_get(string,float)
perhaps only : Menu : WriteMsg
===============================
WriteString(string data, float dest, float desto)
WriteEntity(entity data, float dest, float desto)
-Client & Menu : draw functions
-===============================
+Client & Menu : draw functions & video functions
+===================================================
float iscachedpic(string pic)
string precache_pic(string pic)
drawsetcliparea(float x, float y, float width, float height)
drawresetcliparea()
vector getimagesize(string pic)
-
+
+float cin_open(string file, string name)
+void cin_close(string name)
+void cin_setstate(string name, float type)
+float cin_getstate(string name)
+void cin_restart(string name)
==============================================================================
menu cmd list:
#include "quakedef.h"
#include "progdefs.h"
+#include "progsvm.h"
#include "clprogdefs.h"
#include "mprogdefs.h"
+#include "cl_video.h"
+
//============================================================================
// nice helper macros
}
client = svs.clients + clientnum;
- if (!client->netconnection)
- return;
VM_VarString(1, string, sizeof(string));
MSG_WriteChar(&client->message,svc_print);
MSG_WriteString(&client->message, string);
*/
void VM_random (void)
{
- float num;
-
VM_SAFEPARMCOUNT(0,VM_random);
- num = (rand ()&0x7fff) / ((float)0x7fff);
-
- PRVM_G_FLOAT(OFS_RETURN) = num;
+ PRVM_G_FLOAT(OFS_RETURN) = lhrandom(0, 1);
}
/*
s = PRVM_G_STRING(OFS_PARM0);
- if(!S_LocalSound(s, true))
+ if(!S_LocalSound (s))
{
Con_Printf("VM_localsound: Failed to play %s for %s !\n", s, PRVM_NAME);
PRVM_G_FLOAT(OFS_RETURN) = -4;
if (strcmp(t,s))
continue;
- PRVM_E_FLOAT(ent,chain_of) = PRVM_NUM_FOR_EDICT(chain);
+ PRVM_E_INT(ent,chain_of) = PRVM_NUM_FOR_EDICT(chain);
chain = ent;
}
prog->xfunction->builtinsprofile++;
if (ent->p.e->free)
continue;
- if (E_FLOAT(ent,f) != s)
+ if (PRVM_E_FLOAT(ent,f) != s)
continue;
- PRVM_E_FLOAT(ent,chain_of) = PRVM_NUM_FOR_EDICT(chain);
+ PRVM_E_INT(ent,chain_of) = PRVM_EDICT_TO_PROG(chain);
chain = ent;
}
s = PRVM_G_STRING(OFS_PARM0);
PRVM_G_INT(OFS_RETURN) = PRVM_G_INT(OFS_PARM0);
VM_CheckEmptyString (s);
-
- if(!S_PrecacheSound(s,true, true, true))
+
+ if(!S_PrecacheSound (s,true, true))
Con_Printf("VM_precache_sound: Failed to load %s for %s\n", s, PRVM_NAME);
}
return;
}
- Cvar_Get(name, value, 0);
+ Cvar_Get(name, value, flags);
PRVM_G_FLOAT(OFS_RETURN) = 1; // success
}
for (i = 1;i < prog->argc;i++)
if (PRVM_G_FLOAT((OFS_PARM0+i*3)) > f)
f = PRVM_G_FLOAT((OFS_PARM0+i*3));
- G_FLOAT(OFS_RETURN) = f;
+ PRVM_G_FLOAT(OFS_RETURN) = f;
}
else
PRVM_ERROR("VM_max: %s must supply at least 2 floats\n", PRVM_NAME);
// remove \n following \r
if (c == '\r')
c = FS_Getc(VM_FILES[filenum]);
- if (developer.integer)
+ if (developer.integer >= 3)
Con_Printf("fgets: %s: %s\n", PRVM_NAME, string);
if (c >= 0 || end)
PRVM_G_INT(OFS_RETURN) = PRVM_SetString(string);
{
char *s;
- if(prog->argc < 2)
- PRVM_ERROR("VM_strcat wrong parameter count (min. 2 expected ) !\n");
+ if(prog->argc < 1)
+ PRVM_ERROR("VM_strcat wrong parameter count (min. 1 expected ) !\n");
s = VM_GetTempString();
VM_VarString(0, s, VM_STRINGTEMP_LENGTH);
//void(string s) strunzone = #119; // removes a copy of a string from the string zone (you can not use that string again or it may crash!!!)
void VM_strunzone(void)
{
+ char *str;
VM_SAFEPARMCOUNT(1,VM_strunzone);
- Mem_Free(PRVM_G_STRING(OFS_PARM0));
+ str = PRVM_G_STRING(OFS_PARM0);
+ if( developer.integer && !Mem_IsAllocated( VM_STRINGS_MEMPOOL, str ) )
+ PRVM_ERROR( "VM_strunzone: Zone string already freed in %s!", PRVM_NAME );
+ else
+ Mem_Free( str );
}
/*
VM_SAFEPARMCOUNT(1,VM_iscachedpic);
// drawq hasnt such a function, thus always return true
- PRVM_G_FLOAT(OFS_RETURN) = TRUE;
+ PRVM_G_FLOAT(OFS_RETURN) = false;
}
/*
return;
}
- VM_CheckEmptyString(string);
+ //VM_CheckEmptyString(string); Why should it be checked - perhaps the menu wants to the precolored letters, too?
pos = PRVM_G_VECTOR(OFS_PARM0);
scale = PRVM_G_VECTOR(OFS_PARM2);
float x,y,w,h;
VM_SAFEPARMCOUNT(4,VM_drawsetcliparea);
- x = bound(0,PRVM_G_FLOAT(OFS_PARM0),vid.conwidth);
- y = bound(0,PRVM_G_FLOAT(OFS_PARM1),vid.conheight);
- w = bound(0,PRVM_G_FLOAT(OFS_PARM2),(vid.conwidth - x));
- h = bound(0,PRVM_G_FLOAT(OFS_PARM3),(vid.conheight - y));
+ x = bound(0, PRVM_G_FLOAT(OFS_PARM0), vid.conwidth);
+ y = bound(0, PRVM_G_FLOAT(OFS_PARM1), vid.conheight);
+ w = bound(0, PRVM_G_FLOAT(OFS_PARM2) + PRVM_G_FLOAT(OFS_PARM0) - x, (vid.conwidth - x));
+ h = bound(0, PRVM_G_FLOAT(OFS_PARM3) + PRVM_G_FLOAT(OFS_PARM1) - y, (vid.conheight - y));
- DrawQ_SetClipArea(x,y,w,h);
+ DrawQ_SetClipArea(x, y, w, h);
}
/*
PRVM_G_VECTOR(OFS_RETURN)[2] = 0;
}
+// CL_Video interface functions
+
+/*
+========================
+VM_cin_open
+
+float cin_open(string file, string name)
+========================
+*/
+void VM_cin_open( void )
+{
+ char *file;
+ char *name;
+
+ VM_SAFEPARMCOUNT( 2, VM_cin_open );
+
+ file = PRVM_G_STRING( OFS_PARM0 );
+ name = PRVM_G_STRING( OFS_PARM1 );
+
+ VM_CheckEmptyString( file );
+ VM_CheckEmptyString( name );
+
+ if( CL_OpenVideo( file, name, MENUOWNER ) )
+ PRVM_G_FLOAT( OFS_RETURN ) = 1;
+ else
+ PRVM_G_FLOAT( OFS_RETURN ) = 0;
+}
+
+/*
+========================
+VM_cin_close
+
+void cin_close(string name)
+========================
+*/
+void VM_cin_close( void )
+{
+ char *name;
+
+ VM_SAFEPARMCOUNT( 1, VM_cin_close );
+
+ name = PRVM_G_STRING( OFS_PARM0 );
+ VM_CheckEmptyString( name );
+
+ CL_CloseVideo( CL_GetVideo( name ) );
+}
+
+/*
+========================
+VM_cin_setstate
+void cin_setstate(string name, float type)
+========================
+*/
+void VM_cin_setstate( void )
+{
+ char *name;
+ clvideostate_t state;
+ clvideo_t *video;
+
+ VM_SAFEPARMCOUNT( 2, VM_cin_netstate );
+
+ name = PRVM_G_STRING( OFS_PARM0 );
+ VM_CheckEmptyString( name );
+
+ state = PRVM_G_FLOAT( OFS_PARM1 );
+
+ video = CL_GetVideo( name );
+ if( video && state > CLVIDEO_UNUSED && state < CLVIDEO_STATECOUNT )
+ CL_SetVideoState( video, state );
+}
+
+/*
+========================
+VM_cin_getstate
+
+float cin_getstate(string name)
+========================
+*/
+void VM_cin_getstate( void )
+{
+ char *name;
+ clvideo_t *video;
+
+ VM_SAFEPARMCOUNT( 1, VM_cin_getstate );
+
+ name = PRVM_G_STRING( OFS_PARM0 );
+ VM_CheckEmptyString( name );
+
+ video = CL_GetVideo( name );
+ if( video )
+ PRVM_G_FLOAT( OFS_RETURN ) = (int)video->state;
+ else
+ PRVM_G_FLOAT( OFS_RETURN ) = 0;
+}
+
+/*
+========================
+VM_cin_restart
+
+void cin_restart(string name)
+========================
+*/
+void VM_cin_restart( void )
+{
+ char *name;
+ clvideo_t *video;
+
+ VM_SAFEPARMCOUNT( 1, VM_cin_restart );
+
+ name = PRVM_G_STRING( OFS_PARM0 );
+ VM_CheckEmptyString( name );
+
+ video = CL_GetVideo( name );
+ if( video )
+ CL_RestartVideo( video );
+}
+
+////////////////////////////////////////
+// AltString functions
+////////////////////////////////////////
+
+/*
+========================
+VM_altstr_count
+
+float altstr_count(string)
+========================
+*/
+void VM_altstr_count( void )
+{
+ char *altstr, *pos;
+ int count;
+
+ VM_SAFEPARMCOUNT( 1, VM_altstr_count );
+
+ altstr = PRVM_G_STRING( OFS_PARM0 );
+ VM_CheckEmptyString( altstr );
+
+ for( count = 0, pos = altstr ; *pos ; pos++ )
+ if( *pos == '\\' && !*++pos )
+ break;
+ else if( *pos == '\'' )
+ count++;
+
+ PRVM_G_FLOAT( OFS_RETURN ) = (float) (count / 2);
+}
+
+/*
+========================
+VM_altstr_prepare
+
+string altstr_prepare(string)
+========================
+*/
+void VM_altstr_prepare( void )
+{
+ char *outstr, *out;
+ char *instr, *in;
+ int size;
+
+ VM_SAFEPARMCOUNT( 1, VM_altstr_prepare );
+
+ instr = PRVM_G_STRING( OFS_PARM0 );
+ VM_CheckEmptyString( instr );
+ outstr = VM_GetTempString();
+
+ for( out = outstr, in = instr, size = VM_STRINGTEMP_LENGTH - 1 ; size && *in ; size--, in++, out++ )
+ if( *in == '\'' ) {
+ *out++ = '\\';
+ *out = '\'';
+ size--;
+ } else
+ *out = *in;
+ *out = 0;
+
+ PRVM_G_INT( OFS_RETURN ) = PRVM_SetString( outstr );
+}
+
+/*
+========================
+VM_altstr_get
+
+string altstr_get(string, float)
+========================
+*/
+void VM_altstr_get( void )
+{
+ char *altstr, *pos, *outstr, *out;
+ int count, size;
+
+ VM_SAFEPARMCOUNT( 2, VM_altstr_get );
+
+ altstr = PRVM_G_STRING( OFS_PARM0 );
+ VM_CheckEmptyString( altstr );
+
+ count = PRVM_G_FLOAT( OFS_PARM1 );
+ count = count * 2 + 1;
+
+ for( pos = altstr ; *pos && count ; pos++ )
+ if( *pos == '\\' && !*++pos )
+ break;
+ else if( *pos == '\'' )
+ count--;
+
+ if( !*pos ) {
+ PRVM_G_INT( OFS_RETURN ) = PRVM_SetString( "" );
+ return;
+ }
+
+ outstr = VM_GetTempString();
+ for( out = outstr, size = VM_STRINGTEMP_LENGTH - 1 ; size && *pos ; size--, pos++, out++ )
+ if( *pos == '\\' ) {
+ if( !*++pos )
+ break;
+ *out = *pos;
+ size--;
+ } else if( *pos == '\'' )
+ break;
+ else
+ *out = *pos;
+
+ *out = 0;
+ PRVM_G_INT( OFS_RETURN ) = PRVM_SetString( outstr );
+}
+
void VM_Cmd_Init(void)
{
// only init the stuff for the current prog
void VM_Cmd_Reset(void)
{
//Mem_EmptyPool(VM_STRINGS_MEMPOOL);
+ if( developer.integer >= 2 && VM_STRINGS_MEMPOOL ) {
+ memheader_t *header;
+ int i;
+
+ for( i = 0, header = VM_STRINGS_MEMPOOL->chain ; header ; header = header->next, i++ )
+ Con_DPrintf( "Leaked string %i (size: %i): %.*s\n", i, header->size, header->size, ((char*)header) + sizeof( memheader_t ) );
+ }
+
Mem_FreePool(&VM_STRINGS_MEMPOOL);
+ CL_PurgeOwner( MENUOWNER );
VM_Search_Reset();
VM_Files_CloseAll();
}
// Menu
char *vm_m_extensions =
-"";
+"DP_CINEMATIC_DPV";
/*
=========
else switch(type)
{
case 0:
- PRVM_G_FLOAT ( OFS_RETURN ) = hostCacheCount;
+ PRVM_G_FLOAT ( OFS_RETURN ) = hostcache_viewcount;
return;
case 1:
PRVM_G_FLOAT ( OFS_RETURN ) = masterquerycount;
hostnr = PRVM_G_FLOAT(OFS_PARM1);
- if(hostnr < 0 || hostnr >= hostCacheCount)
+ if(hostnr < 0 || hostnr >= hostcache_viewcount)
{
Con_Print("VM_M_gethostcachestring: bad hostnr passed!\n");
return;
}
if( type == 0 )
- PRVM_G_INT( OFS_RETURN ) = PRVM_SetString( hostcache[hostnr].cname );
+ PRVM_G_INT( OFS_RETURN ) = PRVM_SetString( hostcache_viewset[hostnr]->info.cname );
else if( type == 1 )
- PRVM_G_INT( OFS_RETURN ) = PRVM_SetString( hostcache[hostnr].line1 );
+ PRVM_G_INT( OFS_RETURN ) = PRVM_SetString( hostcache_viewset[hostnr]->line1 );
else
- PRVM_G_INT( OFS_RETURN ) = PRVM_SetString( hostcache[hostnr].line2 );
+ PRVM_G_INT( OFS_RETURN ) = PRVM_SetString( hostcache_viewset[hostnr]->line2 );
}
prvm_builtin_t vm_m_builtins[] = {
VM_search_getfilename, // 77
VM_chr,
VM_itof,
- VM_ftoi,// 80
- e10, // 90
+ VM_ftoi, // 80
+ VM_itof, // isString
+ VM_altstr_count,
+ VM_altstr_prepare,
+ VM_altstr_get, // 84
+ 0,0,0,0,0,0, // 90
e10, // 100
e100, // 200
e100, // 300
VM_drawsetcliparea,
VM_drawresetcliparea,
VM_getimagesize,// 460
- e10, // 470
+ VM_cin_open,
+ VM_cin_close,
+ VM_cin_setstate,
+ VM_cin_getstate,
+ VM_cin_restart, // 465
+ 0,0,0,0,0, // 470
e10, // 480
e10, // 490
e10, // 500