int Start(lua_State *L)
{
	CreateInterfaceFn interfaceFactory = Sys_GetFactory( ENGINE_LIB );
	CreateInterfaceFn gameServerFactory = Sys_GetFactory( SERVER_LIB );
	CreateInterfaceFn physicsFactory = Sys_GetFactory( VPHYSICS_LIB );

	surfaceprop = (IPhysicsSurfaceProps*)physicsFactory(VPHYSICS_SURFACEPROPS_INTERFACE_VERSION, NULL);

	engine = (IVEngineServer*)interfaceFactory(INTERFACEVERSION_VENGINESERVER, NULL);

	ILuaInterface *gLua = Lua();

	ILuaObject *vmeta = gLua->GetMetaTable("Vehicle", GLua::TYPE_ENTITY);

		vmeta->SetMember("GetOperatingParams", getoperatingparams);
		vmeta->SetMember("GetVehicleParams", getvehicleparams);
		vmeta->SetMember("SetVehicleParams", setvehicleparams);
		vmeta->SetMember("SetWheelMaterial", SetWheelMaterial);
		vmeta->SetMember("GetWheelMaterial", GetWheelMaterial);

	vmeta->UnReference();

	gLua->SetGlobal("GetUcmdButtons", GetUcmdButtons);
	gLua->SetGlobal("SetUcmdButtons", SetUcmdButtons);

	return 0;
}
Exemplo n.º 2
0
Arquivo: main.cpp Projeto: DaWhale/VC
int Open(lua_State *L) {
	ml_Lua = Lua();
	
	
	CreateInterfaceFn g_pEngineFactory = Sys_GetFactory("engine.dll"); //Engine
	g_pEngine = (IVEngineClient*)g_pEngineFactory(VENGINE_CLIENT_INTERFACE_VERSION, NULL);
	if (!g_pEngine) {
		ml_Lua->Msg("[gmcl_replicator] Can't get IVEngineClient interface " VENGINE_CLIENT_INTERFACE_VERSION " :(\n");
		return 0;
	}
	
	CreateInterfaceFn VSTDLibFactory = Sys_GetFactory("vstdlib.dll");
	if (!VSTDLibFactory) {
		ml_Lua->Msg("[gmcl_replicator] Error getting vstdlib.dll factory.\n");
		return 0;
	}
	g_ICvar = (ICvar*)VSTDLibFactory(CVAR_INTERFACE_VERSION, NULL);
	if (!g_ICvar) {
		ml_Lua->Msg("[gmcl_replicator] Error getting ICvar " CVAR_INTERFACE_VERSION " interface.\n");
		return 0;
	}
	
	ml_Lua->NewGlobalTable("replicator");
	ILuaObject* replicator = ml_Lua->GetGlobal("replicator");
		replicator->SetMember("ConCommand",			DoClientCommand);
		replicator->SetMember("GetAllConVars",		GetAllCvars);
		replicator->SetMember("GetAllConCommands",	GetAllCmds);
		replicator->SetMember("GetConCommand", 		GetCommand);
	replicator->UnReference();
	
	ml_Lua->SetGlobal("FCVAR_DEVELOPMENTONLY", (float) FCVAR_DEVELOPMENTONLY);
	ml_Lua->SetGlobal("FCVAR_HIDDEN", (float) FCVAR_HIDDEN);
	
	ILuaObject* conVarMeta = ml_Lua->GetMetaTable("ConVar", GLua::TYPE_CONVAR);
	if (conVarMeta) {
		conVarMeta->SetMember("SetValue",		SetConVarValue);
		//conVarMeta->SetMember("GetBool",		GetConVarBool);
		conVarMeta->SetMember("GetDefault",		GetConVarDefault);
		conVarMeta->SetMember("GetFloat",		GetConVarFloat);
		//conVarMeta->SetMember("GetInt",		GetConVarInt);
		conVarMeta->SetMember("GetName",		GetConVarName);
		conVarMeta->SetMember("SetName",		SetConVarName);
		//conVarMeta->SetMember("GetString",	GetConVarString);
		conVarMeta->SetMember("SetFlags",		SetConVarFlags);
		conVarMeta->SetMember("GetFlags",		GetConVarFlags);
		conVarMeta->SetMember("HasFlag",		ConVarHasFlag);
		conVarMeta->SetMember("SetHelpText",	SetConVarHelpText);
		//conVarMeta->SetMember("GetHelpText",	GetConVarHelpText);
		conVarMeta->SetMember("Reset",			ResetConVarValue);
		conVarMeta->SetMember("Remove",			RemoveConVar);
		conVarMeta->SetMember("__tostring",		__tostring);
		conVarMeta->SetMember("__eq",			__eq);
		conVarMeta->SetMember("__index",		conVarMeta);
	}
	conVarMeta->UnReference();
	
	return 0;
}
int main( int argc, char **argv )
{
	const char *pModuleName = "vtex_dll.dll";
	
	CSysModule *pModule = Sys_LoadModule( pModuleName );
	if ( !pModule )
	{
		printf( "Can't load %s.", pModuleName );
		return false;
	}

	CreateInterfaceFn fn = Sys_GetFactory( pModule );
	if ( !fn )
	{
		printf( "Can't get factory from %s.", pModuleName );
		Sys_UnloadModule( pModule );
		return false;
	}

	ILaunchableDLL *pInterface = (ILaunchableDLL*)fn( LAUNCHABLE_DLL_INTERFACE_VERSION, NULL );
	if ( !pInterface )
	{
		printf( "Can't get '%s' interface from %s.", LAUNCHABLE_DLL_INTERFACE_VERSION, pModuleName );
		Sys_UnloadModule( pModule );
		return false;
	}

	int iRet = pInterface->main( argc, argv );
	Sys_UnloadModule( pModule );
	return iRet;
}
void RunInDLL( const char *pFilename, CUtlVector<char*> &newArgv )
{
	if ( g_pConnMgr )						   
		g_pConnMgr->SetAppState( VMPI_SERVICE_STATE_BUSY );

	bool bSuccess = false;
	CSysModule *pModule = Sys_LoadModule( pFilename );
	if ( pModule )
	{
		CreateInterfaceFn fn = Sys_GetFactory( pModule );
		if ( fn )
		{
			ILaunchableDLL *pDLL = (ILaunchableDLL*)fn( LAUNCHABLE_DLL_INTERFACE_VERSION, NULL );
			if( pDLL )
			{
				// Do this here because the executables we would have launched usually would do it.
				CommandLine()->CreateCmdLine( newArgv.Count(), newArgv.Base() );
				pDLL->main( newArgv.Count(), newArgv.Base() );
				bSuccess = true;
				SpewOutputFunc( MySpewOutputFunc );
			}
		}

		Sys_UnloadModule( pModule );
	}
	
	if ( !bSuccess )
	{
		Msg( "Error running VRAD (or VVIS) out of DLL '%s'\n", pFilename );
	}

	if ( g_pConnMgr )
		g_pConnMgr->SetAppState( VMPI_SERVICE_STATE_IDLE );
}
Exemplo n.º 5
0
void LoadMaterialSystemInterface( CreateInterfaceFn fileSystemFactory )
{
	if( g_pMaterialSystem )
		return;
	
	// materialsystem.dll should be in the path, it's in bin along with vbsp.
	const char *pDllName = "materialsystem.dll";
	CSysModule *materialSystemDLLHInst;
	materialSystemDLLHInst = g_pFullFileSystem->LoadModule( pDllName );
	if( !materialSystemDLLHInst )
	{
		Error( "Can't load MaterialSystem.dll\n" );
	}

	CreateInterfaceFn clientFactory = Sys_GetFactory( materialSystemDLLHInst );
	if ( clientFactory )
	{
		g_pMaterialSystem = (IMaterialSystem *)clientFactory( MATERIAL_SYSTEM_INTERFACE_VERSION, NULL );
		if ( !g_pMaterialSystem )
		{
			Error( "Could not get the material system interface from materialsystem.dll (" __FILE__ ")" );
		}
	}
	else
	{
		Error( "Could not find factory interface in library MaterialSystem.dll" );
	}

	if (!g_pMaterialSystem->Init( "shaderapiempty.dll", 0, fileSystemFactory ))
	{
		Error( "Could not start the empty shader (shaderapiempty.dll)!" );
	}
}
//-----------------------------------------------------------------------------
// Purpose: Application entry point
//			Loads and runs the TrackerSRV
//-----------------------------------------------------------------------------
int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
	// winsock aware
	WSAData wsaData;
	int nReturnCode = ::WSAStartup(MAKEWORD(2,0), &wsaData);

	// load the Tracker Server DLL
	CSysModule *serverDll = Sys_LoadModule("TrackerSRV.dll");
	CreateInterfaceFn serverFactory = Sys_GetFactory(serverDll);
	if (!serverFactory)
	{
		::MessageBox(NULL, "Could not load 'TrackerSRV.dll'", "Fatal Error - TrackerServer", MB_OK | MB_ICONERROR);
		return 1;
	}

	ITrackerSRV *trackerInterface = (ITrackerSRV *)serverFactory(TRACKERSERVER_INTERFACE_VERSION, NULL);

	// Activate server
	trackerInterface->RunTrackerServer(lpCmdLine);

	Sys_UnloadModule(serverDll);

	::WSACleanup();

	return 0;
}
Exemplo n.º 7
0
int CL_DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion )
{
	gEngfuncs = *pEnginefuncs;

	RecClInitialize(pEnginefuncs, iVersion);

	if (iVersion != CLDLL_INTERFACE_VERSION)
		return 0;

	memcpy(&gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t));

	EV_HookEvents();
	// get tracker interface, if any
	char szDir[512];
	if (!gEngfuncs.COM_ExpandFilename("Bin/TrackerUI.dll", szDir, sizeof(szDir)))
	{
		g_pTrackerUser = NULL;
		g_hTrackerModule = NULL;
		return 1;
	}

	g_hTrackerModule = Sys_LoadModule(szDir);
	CreateInterfaceFn trackerFactory = Sys_GetFactory(g_hTrackerModule);
	if (!trackerFactory)
	{
		g_pTrackerUser = NULL;
		g_hTrackerModule = NULL;
		return 1;
	}

	g_pTrackerUser = (ITrackerUser *)trackerFactory(TRACKERUSER_INTERFACE_VERSION, NULL);
	return 1;
}
Exemplo n.º 8
0
void CL_LoadParticleMan( void )
{
	char szPDir[512];

	if ( gEngfuncs.COM_ExpandFilename( PARTICLEMAN_DLLNAME, szPDir, sizeof( szPDir ) ) == FALSE )
	{
		g_pParticleMan = NULL;
		g_hParticleManModule = NULL;
		return;
	}

	g_hParticleManModule = Sys_LoadModule( szPDir );
	CreateInterfaceFn particleManFactory = Sys_GetFactory( g_hParticleManModule );

	if ( particleManFactory == NULL )
	{
		g_pParticleMan = NULL;
		g_hParticleManModule = NULL;
		return;
	}

	g_pParticleMan = (IParticleMan *)particleManFactory( PARTICLEMAN_INTERFACE, NULL);

	if ( g_pParticleMan )
	{
		 g_pParticleMan->SetUp( &gEngfuncs );

		 // Add custom particle classes here BEFORE calling anything else or you will die.
		 g_pParticleMan->AddCustomParticleClassSize ( sizeof ( CBaseParticle ) );
	}
}
Exemplo n.º 9
0
void InitStudioRender( void )
{
    if ( g_pStudioRenderModule )
        return;
    Assert( g_MatSysFactory );

    g_pStudioRenderModule = g_pFullFileSystem->LoadModule( "StudioRender.dll" );
    if( !g_pStudioRenderModule )
    {
        MdlError( "Can't load StudioRender.dll\n" );
    }
    CreateInterfaceFn studioRenderFactory = Sys_GetFactory( g_pStudioRenderModule );
    if (!studioRenderFactory )
    {
        MdlError( "Can't get factory for StudioRender.dll\n" );
    }
    g_pStudioRender = ( IStudioRender * )studioRenderFactory( STUDIO_RENDER_INTERFACE_VERSION, NULL );
    if (!g_pStudioRender)
    {
        MdlError( "Unable to init studio render system version %s\n", STUDIO_RENDER_INTERFACE_VERSION );
    }

    g_pStudioRender->Init( g_MatSysFactory, g_ShaderAPIFactory, g_ShaderAPIFactory, Sys_GetFactoryThis() );
    UpdateStudioRenderConfig();
}
Exemplo n.º 10
0
void FileFilter_Load()
{
	CreateInterfaceFn engineFactory =  Sys_GetFactory("engine.dll");

	netstringtables = (INetworkStringTableContainer *)engineFactory(INTERFACENAME_NETWORKSTRINGTABLESERVER, NULL);
	if(netstringtables == NULL)
	{
		Msg("Unable to find string tables!\n");
		return;
	}

	CSigScan::sigscan_dllfunc = engineFactory;
	bool scan = CSigScan::GetDllMemInfo();

	sigcheckfileext_Sig.Init((unsigned char *)SIG_CHECKFILE, SIG_CHECKFILEMASK, SIG_CHECKFILELEN);

	Msg("CheckFile signature %x\n", sigcheckfileext_Sig.sig_addr);

	if(sigcheckfileext_Sig.sig_addr)
	{
		checkext_trampoline = (checkext_t)sigcheckfileext_Sig.sig_addr;

		DetourTransactionBegin();
		DetourUpdateThread(GetCurrentThread());
			DetourAttach(&(PVOID&)checkext_trampoline, (PVOID)(&(PVOID&)checkext_hook));
		DetourTransactionCommit();
	}
	else
	{
		Msg("Couldn't find CheckFile function!\n");
		return;
	}
}
Exemplo n.º 11
0
int main(int argc, char* argv[])
{
	CommandLine()->CreateCmdLine( argc, argv );
	const char *pDLLName = "vvis_dll.dll";
	
	CSysModule *pModule = Sys_LoadModule( pDLLName );
	if ( !pModule )
	{
		printf( "vvis launcher error: can't load %s\n%s", pDLLName, GetLastErrorString() );
		return 1;
	}

	CreateInterfaceFn fn = Sys_GetFactory( pModule );
	if( !fn )
	{
		printf( "vvis launcher error: can't get factory from %s\n", pDLLName );
		Sys_UnloadModule( pModule );
		return 2;
	}

	int retCode = 0;
	ILaunchableDLL *pDLL = (ILaunchableDLL*)fn( LAUNCHABLE_DLL_INTERFACE_VERSION, &retCode );
	if( !pDLL )
	{
		printf( "vvis launcher error: can't get IVVisDLL interface from %s\n", pDLLName );
		Sys_UnloadModule( pModule );
		return 3;
	}

	pDLL->main( argc, argv );
	Sys_UnloadModule( pModule );

	return 0;
}
Exemplo n.º 12
0
//-----------------------------------------------------------------------------
// Purpose: get the interface for the specified module and version
// Input  : 
// Output : 
//-----------------------------------------------------------------------------
bool Sys_LoadInterface(
	const char *pModuleName,
	const char *pInterfaceVersionName,
	CSysModule **pOutModule,
	void **pOutInterface )
{
	CSysModule *pMod = Sys_LoadModule( pModuleName );
	if ( !pMod )
		return false;

	CreateInterfaceFn fn = Sys_GetFactory( pMod );
	if ( !fn )
	{
		Sys_UnloadModule( pMod );
		return false;
	}

	*pOutInterface = fn( pInterfaceVersionName, NULL );
	if ( !( *pOutInterface ) )
	{
		Sys_UnloadModule( pMod );
		return false;
	}

	if ( pOutModule )
		*pOutModule = pMod;

	return true;
}
Exemplo n.º 13
0
static void LoadMaterialSystem( void )
{
	if( g_pMaterialSystem )
		return;
	
	const char *pDllName = "materialsystem.dll";
	CSysModule *materialSystemDLLHInst;
	materialSystemDLLHInst = g_pFullFileSystem->LoadModule( pDllName );
	if( !materialSystemDLLHInst )
	{
		MdlError( "Can't load MaterialSystem.dll\n" );
	}

	g_MatSysFactory = Sys_GetFactory( materialSystemDLLHInst );
	if ( g_MatSysFactory )
	{
		g_pMaterialSystem = (IMaterialSystem *)g_MatSysFactory( MATERIAL_SYSTEM_INTERFACE_VERSION, NULL );
		if ( !g_pMaterialSystem )
		{
			MdlError( "Could not get the material system interface from materialsystem.dll" );
		}
	}
	else
	{
		MdlError( "Could not find factory interface in library MaterialSystem.dll" );
	}

	if (!( g_ShaderAPIFactory = g_pMaterialSystem->Init( "shaderapiempty.dll", 0, CmdLib_GetFileSystemFactory() )) )
	{
		MdlError( "Could not start the empty shader (shaderapiempty.dll)!" );
	}
}
Exemplo n.º 14
0
bool LoadShaderDLL( const char *pFilename )
{
    // Load the new shader
    CSysModule *hInstance = g_pFullFileSystem->LoadModule( pFilename );
    if ( !hInstance )
        return false;

    // Get at the shader DLL interface
    CreateInterfaceFn factory = Sys_GetFactory( hInstance );
    if (!factory)
    {
        g_pFullFileSystem->UnloadModule( hInstance );
        return false;
    }

    IShaderDLLInternal *pShaderDLL = (IShaderDLLInternal*)factory( SHADER_DLL_INTERFACE_VERSION, NULL );
    if ( !pShaderDLL )
    {
        g_pFullFileSystem->UnloadModule( hInstance );
        return false;
    }

    CShaderDLLInfo *pOut = &g_ShaderDLLs[ g_ShaderDLLs.AddToTail() ];
    pOut->m_pInternal = pShaderDLL;
    Q_strncpy( pOut->m_Filename, pFilename, sizeof( pOut->m_Filename ) );

    return true;
}
Exemplo n.º 15
0
CreateInterfaceFn FileSystem_GetFactory()
{
#if defined( MPI )
	if ( g_bUseMPI )
		return VMPI_FileSystem_GetFactory();
#endif
	return Sys_GetFactory( g_pFullFileSystemModule );
}
Exemplo n.º 16
0
int EXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion )
{
    gEngfuncs = *pEnginefuncs;

    //!!! mwh UNDONE We need to think about our versioning strategy. Do we want to try to be compatible
    // with previous versions, especially when we're only 'bonus' functionality? Should it be the engine
    // that decides if the DLL is compliant?

    if (iVersion != CLDLL_INTERFACE_VERSION)
        return 0;

    memcpy(&gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t));

    EV_HookEvents();

    // Determine which filesystem to use.
#if defined ( _WIN32 )
    char *szFsModule = "filesystem_stdio.dll";
#elif defined(OSX)
    char *szFsModule = "filesystem_stdio.dylib";
#elif defined(LINUX)
    char *szFsModule = "filesystem_stdio.so";
#else
#error
#endif


    char szFSDir[MAX_PATH];
    szFSDir[0] = 0;
    if ( gEngfuncs.COM_ExpandFilename( szFsModule, szFSDir, sizeof( szFSDir ) ) == FALSE )
    {
        return false;
    }

    // Get filesystem interface.
    g_pFileSystemModule = Sys_LoadModule( szFSDir );
    assert( g_pFileSystemModule );
    if( !g_pFileSystemModule )
    {
        return false;
    }

    CreateInterfaceFn fileSystemFactory = Sys_GetFactory( g_pFileSystemModule );
    if( !fileSystemFactory )
    {
        return false;
    }

    g_pFileSystem = ( IFileSystem * )fileSystemFactory( FILESYSTEM_INTERFACE_VERSION, NULL );
    assert( g_pFileSystem );
    if( !g_pFileSystem )
    {
        return false;
    }

    return 1;
}
Exemplo n.º 17
0
//-----------------------------------------------------------------------------
// Purpose: Adds tool from specified library
// Input  : *dllname - 
//-----------------------------------------------------------------------------
void CToolFrameworkInternal::LoadToolsFromLibrary( const char *dllname )
{
	CSysModule *module = Sys_LoadModule( dllname );
	if ( !module )
	{
		Warning( "CToolFrameworkInternal::LoadToolsFromLibrary:  Unable to load '%s'\n", dllname );
		return;
	}

	CreateInterfaceFn factory = Sys_GetFactory( module );
	if ( !factory )
	{
		Sys_UnloadModule( module );
		Warning( "CToolFrameworkInternal::LoadToolsFromLibrary:  Dll '%s' has no factory\n", dllname );
		return;
	}

	IToolDictionary *dictionary = ( IToolDictionary * )factory( VTOOLDICTIONARY_INTERFACE_VERSION, NULL );
	if ( !dictionary )
	{
		Sys_UnloadModule( module );
		Warning( "CToolFrameworkInternal::LoadToolsFromLibrary:  Dll '%s' doesn't support '%s'\n", dllname, VTOOLDICTIONARY_INTERFACE_VERSION );
		return;
	}

	if ( !dictionary->Connect( g_AppSystemFactory ) )
	{
		Sys_UnloadModule( module );
		Warning( "CToolFrameworkInternal::LoadToolsFromLibrary:  Dll '%s' connection phase failed.\n", dllname );
		return;
	}

	if ( dictionary->Init( ) != INIT_OK )
	{
		Sys_UnloadModule( module );
		Warning( "CToolFrameworkInternal::LoadToolsFromLibrary:  Dll '%s' initialization phase failed.\n", dllname );
		return;
	}

	dictionary->CreateTools();

	int toolCount = dictionary->GetToolCount();
	for ( int i = 0; i < toolCount; ++i )
	{
		IToolSystem *tool = dictionary->GetTool( i );
		if ( tool )
		{
			Msg( "Loaded tool '%s'\n", tool->GetToolName() );
			m_ToolSystems.AddToTail( tool );
		}
	}

	m_Dictionaries.AddToTail( dictionary );
	m_Modules.AddToTail( module );
}
Exemplo n.º 18
0
//-----------------------------------------------------------------------------
// The application object
//-----------------------------------------------------------------------------
bool CUnitTestApp::Create()
{
	// Install a special Spew handler that ignores all assertions and lets us
	// run for as long as possible
	SpewOutputFunc( UnitTestSpew );

	// FIXME: This list of dlls should come from the unittests themselves
	AppSystemInfo_t appSystems[] = 
	{
		{ "vstdlib.dll",			PROCESS_UTILS_INTERFACE_VERSION },
		{ "", "" }	// Required to terminate the list
	};

	if ( !AddSystems( appSystems ) ) 
		return false;

	// Very simple... just iterate over all .DLLs in the current directory 
	// see if they export UNITTEST_INTERFACE_VERSION. If not, then unload them
	// just as quick.

	// We may want to make this more sophisticated, giving it a search path,
	// or giving test DLLs special extensions, or statically linking the test DLLs
	// to this program.

	WIN32_FIND_DATA findFileData;
	HANDLE hFind= FindFirstFile("*.dll", &findFileData);

	while (hFind != INVALID_HANDLE_VALUE)
	{
		CSysModule* hLib = Sys_LoadModule(findFileData.cFileName);
		if ( hLib )
		{
			CreateInterfaceFn factory = Sys_GetFactory( hLib );
			if ( factory && factory( UNITTEST_INTERFACE_VERSION, NULL ) )
			{
				AppModule_t module = LoadModule( factory );
				AddSystem( module, UNITTEST_INTERFACE_VERSION );
			}
			else
			{
				Sys_UnloadModule( hLib );
			}
		}

		if (!FindNextFile( hFind, &findFileData ))
			break;
	}

	return true;
}
Exemplo n.º 19
0
void Hook_DemoPlayer(void * hModule)
{
	static bool firstRun = true;
	if(!firstRun) return;
	firstRun = false;

	CreateInterfaceFn demoPlayerCreateInterface = Sys_GetFactory((CSysModule *)hModule);

	if(0 != demoPlayerCreateInterface)
	{
		int returnCode = 0;
		g_DemoPlayer = (IDemoPlayer001 *)demoPlayerCreateInterface("demoplayer001", &returnCode);
	}
}
Exemplo n.º 20
0
CreateInterfaceFn CDllDemandLoader::GetFactory()
{
	if ( !m_hModule && !m_bLoadAttempted )
	{
		m_bLoadAttempted = true;
		m_hModule = Sys_LoadModule( m_pchModuleName );
	}

	if ( !m_hModule )
	{
		return NULL;
	}

	return Sys_GetFactory( m_hModule );
}
//-----------------------------------------------------------------------------
// Purpose: sets up all the modules for use
//-----------------------------------------------------------------------------
bool CVGuiSystemModuleLoader::InitializeAllModules(CreateInterfaceFn *factorylist, int factorycount)
{
	if ( IsX360() )
	{
		// not valid for 360
		return false;
	}

	bool bSuccess = true;

	// Init vgui in the modules
	int i;
	for ( i = 0; i < m_Modules.Count(); i++ )
	{
		if (!m_Modules[i].moduleInterface->Initialize(factorylist, factorycount))
		{
			bSuccess = false;
			Error("Platform Error: module failed to initialize\n");
		}
	}

	// create a table of all the loaded modules
	CreateInterfaceFn *moduleFactories = (CreateInterfaceFn *)_alloca(sizeof(CreateInterfaceFn) * m_Modules.Count());
	for ( i = 0; i < m_Modules.Count(); i++ )
	{
		moduleFactories[i] = Sys_GetFactory(m_Modules[i].module);
	}

	// give the modules a chance to link themselves together
	for (i = 0; i < m_Modules.Count(); i++)
	{
		if (!m_Modules[i].moduleInterface->PostInitialize(moduleFactories, m_Modules.Count()))
		{
			bSuccess = false;
			Error("Platform Error: module failed to initialize\n");
		}
		
#ifdef GAMEUI_EXPORTS
		m_Modules[i].moduleInterface->SetParent(GetGameUIBasePanel());
#else
		m_Modules[i].moduleInterface->SetParent(g_pMainPanel->GetVPanel());		
#endif
	}

	m_bModulesInitialized = true;
	return bSuccess;
}
Exemplo n.º 22
0
// ------------------------------------------------------------------------ //
// Global functions.
// ------------------------------------------------------------------------ //
IFileSystem* ScratchPad3D_SetupFileSystem()
{
	// Get a filesystem interface.
	CSysModule *pModule = Sys_LoadModule( "filesystem_stdio" );
	if( !pModule )
		return NULL;

	CreateInterfaceFn fn = Sys_GetFactory( pModule );
	IFileSystem *pFileSystem;
	if( !fn || (pFileSystem = (IFileSystem *)fn( FILESYSTEM_INTERFACE_VERSION, NULL )) == NULL )
	{
		Sys_UnloadModule( pModule );
		return NULL;
	}

	return pFileSystem;
}
Exemplo n.º 23
0
void LoadFileSystem( void )
{
	hFileSystemModule = Sys_LoadModule( FILESYSTEM_DLLNAME );
	CreateInterfaceFn fileSystemFactory = Sys_GetFactory( hFileSystemModule );

	if( fileSystemFactory == NULL )
	{
		g_pFileSystem = NULL;
	}

	g_pFileSystem = (IFileSystem *)fileSystemFactory( FILESYSTEM_INTERFACE_VERSION, NULL );

	if( g_pFileSystem )
	{
		ALERT( at_aiconsole, "%s interface instantiated.\n", FILESYSTEM_INTERFACE_VERSION );
	}
}
Exemplo n.º 24
0
IBaseInterface *CreateFileSystemInterface()
{
	if (g_pOriginalFileSystem)
		return g_pOriginalFileSystem;

	if (g_pOriginalFileSystemModule)
	{
		g_OriginalFileSystemFactory = Sys_GetFactory(g_pOriginalFileSystemModule);
		if (g_OriginalFileSystemFactory)
		{
			int returnCode = 0;
			g_pOriginalFileSystem = reinterpret_cast<IBaseFileSystem *>(g_OriginalFileSystemFactory(FILESYSTEM_INTERFACE_VERSION, &returnCode));
			return g_pOriginalFileSystem;
		}
	}

	return NULL;
}
Exemplo n.º 25
0
SystemWrapper::library_t *SystemWrapper::GetLibrary(char *name)
{
	char fixedname[MAX_PATH];
	Q_strlcpy(fixedname, name);
	COM_FixSlashes(fixedname);

	library_t *lib = (library_t *)m_Libraries.GetFirst();
	while (lib)
	{
		if (Q_stricmp(lib->name, name) == 0) {
			return lib;
		}

		lib = (library_t *)m_Libraries.GetNext();
	}

	lib = (library_t *)Mem_Malloc(sizeof(library_t));
	if (!lib) {
		DPrintf("ERROR! System::GetLibrary: out of memory (%s).\n", name);
		return nullptr;
	}

	Q_snprintf(lib->name, sizeof(lib->name), "%s." LIBRARY_PREFIX, fixedname);
	FS_GetLocalCopy(lib->name);

	lib->handle = (CSysModule *)Sys_LoadModule(lib->name);
	if (!lib->handle) {
		DPrintf("ERROR! System::GetLibrary: coulnd't load library (%s).\n", lib->name);
		Mem_Free(lib);
		return nullptr;
	}

	lib->createInterfaceFn = (CreateInterfaceFn)Sys_GetFactory(lib->handle);
	if (!lib->createInterfaceFn) {
		DPrintf("ERROR! System::GetLibrary: coulnd't get object factory(%s).\n", lib->name);
		Mem_Free(lib);
		return nullptr;
	}

	m_Libraries.Add(lib);
	DPrintf("Loaded library %s.\n", lib->name);

	return lib;
}
bool ConnectShaderPostprocessInterface()
{
	char modulePath[MAX_PATH*4];
	Q_snprintf( modulePath, sizeof( modulePath ), "%s/bin/game_shader_dx9.dll", engine->GetGameDirectory() );
	__g_pShaderAPIShaderModule = Sys_LoadModule( modulePath );

	if ( __g_pShaderAPIShaderModule )
	{
		CreateInterfaceFn shaderShaderAPIDLLFactory = Sys_GetFactory( __g_pShaderAPIShaderModule );
		__g_shaderExt = shaderShaderAPIDLLFactory ? ((IShaderEnginePostprocessInterface *)shaderShaderAPIDLLFactory(POSTPROCESS_INTERFACE_VERSION, NULL)) : NULL;

		if ( !__g_shaderExt )
			Warning( "Unable to pull IShaderEnginePostprocessInterface interface.\n" );
	}
	else
		Warning( "Cannot load game_shader_dx9.dll from %s!\n", modulePath );

	return __g_shaderExt != NULL;
}
Exemplo n.º 27
0
int Init(lua_State* L)
{
	gLua = Lua();

	CreateInterfaceFn engineFactory	= Sys_GetFactory("engine.dll");

	engine = (IVEngineServer*)engineFactory(INTERFACEVERSION_VENGINESERVER, NULL);

	if(!engine)
	{
		gLua->Error("gmsv_teleport: Failed to load IVEngineServer\n");
	}

	Msg("gmsv_teleport: Loaded\n");

	ILuaObject *oEntity = gLua->GetGlobal("Entity");
	oEntity->Push();
	refEntity = gLua->GetReference(-1, true);
	oEntity->UnReference();

	ILuaObject *ohook = gLua->GetGlobal("hook");
		ILuaObject *oCall = ohook->GetMember("Call");
		oCall->Push();
		refHookCall = gLua->GetReference(-1, true);
		oCall->UnReference();
	ohook->UnReference();

	ILuaObject *oEntityMeta = gLua->GetMetaTable("Entity", GLua::TYPE_ENTITY);
		ILuaObject *oEntIndex = oEntityMeta->GetMember("EntIndex");
		oEntIndex->Push();
		refEntIndex = gLua->GetReference(-1, true);
		oEntIndex->UnReference();
	oEntityMeta->UnReference();

	ILuaObject *entityMeta = gLua->GetMetaTable("Entity", GLua::TYPE_ENTITY);
	if(entityMeta)
	{
		entityMeta->SetMember("SetupTeleportHook", SetupTeleportHook);
	}
    entityMeta->UnReference();

	return 0;
}
Exemplo n.º 28
0
bool ConnectDeferredExt()
{
	char modulePath[MAX_PATH*4];
	Q_snprintf( modulePath, sizeof( modulePath ), "%s/bin/game_shader_generic_deferred.dll\0", engine->GetGameDirectory() );
	__g_pDeferredShaderModule = Sys_LoadModule( modulePath );

	if ( __g_pDeferredShaderModule )
	{
		CreateInterfaceFn shaderDeferredDLLFactory = Sys_GetFactory( __g_pDeferredShaderModule );
		__g_defExt = shaderDeferredDLLFactory ? ((IDeferredExtension *) shaderDeferredDLLFactory( DEFERRED_EXTENSION_VERSION, NULL )) : NULL;

		if ( !__g_defExt )
			Warning( "Unable to pull IDeferredExtension interface.\n" );
	}
	else
		Warning( "Cannot load game_shader_generic_deferred.dll from %s!\n", modulePath );

	return __g_defExt != NULL;
}
Exemplo n.º 29
0
void ConnectHaptics(CreateInterfaceFn appFactory)
{
	bool success = false;
	// NVNT load haptics module
	pFalconModule = Sys_LoadModule( HAPTICS_TEST_PREFIX HAPTICS_DLL_NAME );
	if(pFalconModule)
	{
		CreateInterfaceFn factory = Sys_GetFactory( pFalconModule );
		if(factory)
		{
			haptics = reinterpret_cast< IHaptics* >( factory( HAPTICS_INTERFACE_VERSION, NULL ) );
			if(haptics && 
				haptics->Initialize(engine,
					view,
					g_InputInternal,
					gpGlobals,
					appFactory,
					g_pVGuiInput->GetIMEWindow(),
					filesystem,
					enginevgui,
					ActivityList_IndexForName,
					ActivityList_NameForIndex))
			{
				success = true;
				hap_HasDevice.SetValue(1);
			}
		}
	}
	if(!success)
	{
		Sys_UnloadModule(pFalconModule);
		pFalconModule = 0;
		haptics = new CHapticsStubbed;
	}

	if(haptics->HasDevice())
	{
		Assert( (void*)haptics == inputsystem->GetHapticsInterfaceAddress() );
	}
	HookHapticMessages();
}
Exemplo n.º 30
0
bool CPluginHandle::LoadFromFile(const tString &asPath)
{
	msPrevPath = asPath;
	
	if(!(mpHandle = LibUtil::LoadLibrary(asPath.c_str())))
		return false;
	
	CreateInterfaceFn fnCreateInterface = Sys_GetFactory((CSysModule*)mpHandle);
	if(fnCreateInterface)
	{
		if(!(mpCallbacks = (IEnginePlugin*)fnCreateInterface(MGT_ENGINEPLUGIN_INTERFACE_VERSION, nullptr)))
			return false;
		
		if(!mpCallbacks->Load(mfnModuleFactory))
			return false;
		
		mpCallbacks->GetInfo(*mpInfo);
	};
	
	return true;
};