示例#1
0
//-----------------------------------------------------------------------------
// Purpose: called when the plugin is loaded, load the interface we need from the engine
//-----------------------------------------------------------------------------
bool CSourcePython::Load(	CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory )
{
	// This seems to be new with
#ifdef ENGINE_CSGO
	ConnectInterfaces(&interfaceFactory, 1);
#else
	ConnectTier1Libraries( &interfaceFactory, 1 );
	ConnectTier2Libraries( &interfaceFactory, 2 );
#endif

	// Get all engine interfaces.
	if( !GetInterfaces(gEngineInterfaces, interfaceFactory) ) {
		return false;
	}

	// Get all game interfaces.
	if( !GetInterfaces(gGameInterfaces, gameServerFactory) ) {
		return false;
	}

	gpGlobals = playerinfomanager->GetGlobalVars();

	MathLib_Init( 2.2f, 2.2f, 0.0f, 2.0f );
	InitCommands();

	// Initialize game paths.
	if( !g_GamePaths.Initialize() ) {
		DevMsg(0, "Could not initialize game paths.");
		return false;
	}

	// Initialize python
	if( !g_PythonManager.Initialize() ) {
		DevMsg(0, "Could not initialize python.");
		return false;
	}

	return true;
}
示例#2
0
//-----------------------------------------------------------------------------
// Purpose: called when the plugin is loaded, load the interface we need from the engine
//-----------------------------------------------------------------------------
bool CSourcePython::Load(	CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory )
{
	// This seems to be new with
#ifdef ENGINE_CSGO
	DevMsg(1, MSG_PREFIX "Connecting interfaces...\n");
	ConnectInterfaces(&interfaceFactory, 1);
#else
	DevMsg(1, MSG_PREFIX "Connecting tier1 libraries...\n");
	ConnectTier1Libraries( &interfaceFactory, 1 );

	DevMsg(1, MSG_PREFIX "Connecting tier2 libraries...\n");
	ConnectTier2Libraries( &interfaceFactory, 2 );
#endif

	// Get all engine interfaces.
	DevMsg(1, MSG_PREFIX "Retrieving engine interfaces...\n");
	if( !GetInterfaces(gEngineInterfaces, interfaceFactory) ) {
		return false;
	}

	// Get all game interfaces.
	DevMsg(1, MSG_PREFIX "Retrieving game interfaces...\n");
	if( !GetInterfaces(gGameInterfaces, gameServerFactory) ) {
		return false;
	}
	
	DevMsg(1, MSG_PREFIX "Retrieving global variables...\n");
	gpGlobals = playerinfomanager->GetGlobalVars();
	if (!gpGlobals) {
		Msg(MSG_PREFIX "Could retrieve global variables.\n");
		return false;
	}
	
	DevMsg(1, MSG_PREFIX "Initializing mathlib...\n");
	MathLib_Init( 2.2f, 2.2f, 0.0f, 2.0f );

	DevMsg(1, MSG_PREFIX "Initializing server and say commands...\n");
	InitCommands();

	// Initialize python
	DevMsg(1, MSG_PREFIX "Initializing python...\n");
	if( !g_PythonManager.Initialize() ) {
		Msg(MSG_PREFIX "Could not initialize python.\n");
		return false;
	}

	// TODO: Don't hardcode the 64 bytes offset
#ifdef ENGINE_LEFT4DEAD2
	#define CACHE_NOTIFY_OFFSET 68
#else
	#define CACHE_NOTIFY_OFFSET 64
#endif

	DevMsg(1, MSG_PREFIX "Retrieving the current cache notifier...\n");
	m_pOldMDLCacheNotifier = *(IMDLCacheNotify **)(((unsigned long) modelcache) + CACHE_NOTIFY_OFFSET);

	DevMsg(1, MSG_PREFIX "Setting the new cache notifier...\n");
	modelcache->SetCacheNotify(this);
	
	Msg(MSG_PREFIX "Loaded successfully.\n");
	return true;
}
示例#3
0
//-----------------------------------------------------------------------------
// Call this to connect to all tier 1 libraries.
// It's up to the caller to check the globals it cares about to see if ones are missing
//-----------------------------------------------------------------------------
void ConnectTier1Libraries( CreateInterfaceFn *pFactoryList, int nFactoryCount )
{
	ConnectInterfaces( pFactoryList, nFactoryCount);
}