#include "progdefs.h" // generated by program cdefs
#include "clprogdefs.h" // generated by program cdefs
+#ifdef SUPPORT_GECKO
+// forward declaration of clgecko_t
+typedef struct clgecko_s clgecko_t;
+#endif
+
typedef struct prvm_stack_s
{
int s;
#define PRVM_MAX_OPENFILES 256
#define PRVM_MAX_OPENSEARCHES 128
+#ifdef SUPPORT_GECKO
+#define PRVM_MAX_GECKOINSTANCES 32
+#endif
typedef void (*prvm_builtin_t) (void);
qfile_t *openfiles[PRVM_MAX_OPENFILES];
fssearch_t *opensearches[PRVM_MAX_OPENSEARCHES];
+#ifdef SUPPORT_GECKO
+ clgecko_t *opengeckoinstances[PRVM_MAX_GECKOINSTANCES];
+#endif
// copies of some vars that were former read from sv
int num_edicts;
}
#ifdef SUPPORT_GECKO
-static const char *vm_gecko_getfullname( const char *name ) {
- // FIXME: assert that PRVM_NAME is not empty.. [12/3/2007 Black]
- return va( "%s/%s", PRVM_NAME, name );
+/*
+========================
+VM_Gecko_Init
+========================
+*/
+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]
+}
+
+/*
+========================
+VM_Gecko_Destroy
+========================
+*/
+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;
+ }
}
/*
*/
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 );
- if( !CL_Gecko_CreateBrowser( vm_gecko_getfullname( 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 );
+ if( !instance ) {
// TODO: error handling [12/3/2007 Black]
PRVM_G_FLOAT( OFS_RETURN ) = 0;
return;
name = PRVM_G_STRING( OFS_PARM0 );
VM_CheckEmptyString( name );
- instance = CL_Gecko_FindBrowser( vm_gecko_getfullname( name ) );
+ instance = CL_Gecko_FindBrowser( name );
if( !instance ) {
return;
}
VM_CheckEmptyString( name );
VM_CheckEmptyString( URI );
- instance = CL_Gecko_FindBrowser( vm_gecko_getfullname( name ) );
+ instance = CL_Gecko_FindBrowser( name );
if( !instance ) {
return;
}
return;
}
- instance = CL_Gecko_FindBrowser( vm_gecko_getfullname( name ) );
+ instance = CL_Gecko_FindBrowser( name );
if( !instance ) {
PRVM_G_FLOAT( OFS_RETURN ) = 0;
return;
x = PRVM_G_FLOAT( OFS_PARM1 );
y = PRVM_G_FLOAT( OFS_PARM2 );
- instance = CL_Gecko_FindBrowser( vm_gecko_getfullname( name ) );
+ instance = CL_Gecko_FindBrowser( name );
if( !instance ) {
return;
}
// only init the stuff for the current prog
VM_Files_Init();
VM_Search_Init();
+#ifdef SUPPORT_GECKO
+ VM_Gecko_Init();
+#endif
// VM_BufStr_Init();
}
CL_PurgeOwner( MENUOWNER );
VM_Search_Reset();
VM_Files_CloseAll();
+#ifdef SUPPORT_GECKO
+ VM_Gecko_Destroy();
+#endif
// VM_BufStr_ShutDown();
}