コード例 #1
0
ファイル: mdlviewer.cpp プロジェクト: newroob/bg2-2007
//-----------------------------------------------------------------------------
// Init, shutdown
//-----------------------------------------------------------------------------
bool CHLModelViewerApp::PreInit( )
{
	CreateInterfaceFn factory = GetFactory();
	ConnectTier1Libraries( &factory, 1 );
	ConVar_Register( 0 );

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

	// Add paths...
	if ( !SetupSearchPaths( NULL, false, true ) )
		return false;

	// Get the adapter from the command line....
	const char *pAdapterString;
	int nAdapter = 0;
	if (CommandLine()->CheckParm( "-adapter", &pAdapterString ))
	{
		nAdapter = atoi( pAdapterString );
	}

	int nAdapterFlags = 0;
	if ( CommandLine()->CheckParm( "-ref" ) )
	{
		nAdapterFlags |= MATERIAL_INIT_REFERENCE_RASTERIZER;
	}

	g_pMaterialSystem->SetAdapter( nAdapter, nAdapterFlags );

	if ( !g_pFileSystem->IsSteam() || CommandLine()->FindParm( "-OldDialogs" ) )
		g_bOldFileDialogs = true;
	
	LoadFileSystemDialogModule();

	return true; 
}
コード例 #2
0
ファイル: gameui2_interface.cpp プロジェクト: Asunaya/game
void CGameUI2::Initialize(CreateInterfaceFn appFactory)
{
	MEM_ALLOC_CREDIT();
	ConnectTier1Libraries(&appFactory, 1);
	ConnectTier2Libraries(&appFactory, 1);
	ConVar_Register(FCVAR_CLIENTDLL);
	ConnectTier3Libraries(&appFactory, 1);

	engine = static_cast<IVEngineClient*>(appFactory(VENGINE_CLIENT_INTERFACE_VERSION, nullptr));
	enginesound = static_cast<IEngineSound*>(appFactory(IENGINESOUND_CLIENT_INTERFACE_VERSION, nullptr));
	enginevgui = static_cast<IEngineVGui*>(appFactory(VENGINE_VGUI_VERSION, nullptr));
	soundemitterbase = static_cast<ISoundEmitterSystemBase*>(appFactory(SOUNDEMITTERSYSTEM_INTERFACE_VERSION, nullptr));
	render = static_cast<IVRenderView*>(appFactory(VENGINE_RENDERVIEW_INTERFACE_VERSION, nullptr));

	CreateInterfaceFn gameUIFactory = g_GameUI.GetFactory();
	if (gameUIFactory)
		gameui = static_cast<IGameUI*>(gameUIFactory(GAMEUI_INTERFACE_VERSION, nullptr));

	if (!enginesound || !enginevgui || !engine || !soundemitterbase || !render || !gameui)
		Error("CGameUI2::Initialize() failed to get necessary interfaces.\n");

    if (!CommandLine()->FindParm("-shaderedit"))
    {
        GetBasePanel()->Create();
        if (GetBasePanel())
            gameui->SetMainMenuOverride(GetBasePanel()->GetMainMenu()->GetVPanel());
    }
}
コード例 #3
0
ファイル: plugin.cpp プロジェクト: kanekikun420/NoCheatZ-3
//---------------------------------------------------------------------------------
// Purpose: called when the plugin is loaded, load the interface we need from the engine
//---------------------------------------------------------------------------------
bool CNoCheatZPlugin::Load(CreateInterfaceFn _interfaceFactory, CreateInterfaceFn gameServerFactory )
{
	ConnectTier1Libraries( &_interfaceFactory, 1 );
	if(g_pCVar->FindVar("nocheatz_instance"))
	{
		if(g_pCVar->FindVar("nocheatz_instance")->GetInt() == 1)
		{
			Error("[NoCheatZ 4] CNoCheatZPlugin - Error : CNoCheatZPlugin already loaded.\n");
			m_bAlreadyLoaded = true;
			return false;
		}
	}
	//ConnectTier2Libraries( &interfaceFactory, 1 );

	CIFaceManager::GetInstance()->UpdateIFactoryPtr(interfaceFactory, (void*)_interfaceFactory);
	CIFaceManager::GetInstance()->UpdateIFactoryPtr(gameFactory, (void*)gameServerFactory);
	NczPlayerManager::GetInstance()->LoadPlayerManager(); // Mark any present player as PLAYER_CONNECTED

	ConVar_Register( 0 );

	EyeAnglesTester::GetInstance();
	JumpTester::GetInstance();
	ValidationTester::GetInstance();
	ConVarTester::GetInstance();
	ShotTester::GetInstance();
	SpeedTester::GetInstance();

	CIFaceManager::GetInstance()->GetIengine()->ServerExecute();
	CIFaceManager::GetInstance()->GetIengine()->ServerCommand("exec nocheatz.cfg\n");
	CIFaceManager::GetInstance()->GetIengine()->ServerExecute();

	for(int i = 0; i < MAX_PLAYERS; ++i)
	{
		PlayerHandler* ph = NczPlayerManager::GetInstance()->GetPlayerHandlerByIndex(i);
		if(ph->status == PLAYER_CONNECTED)
		{
			HookBasePlayer(ph->playerClass);
			LoadTestersByConfig();
			ValidationTester::GetInstance()->ResetPlayerDataStruct(ph->playerClass);
			JumpTester::GetInstance()->ResetPlayerDataStruct(ph->playerClass);
			EyeAnglesTester::GetInstance()->ResetPlayerDataStruct(ph->playerClass);
			ConVarTester::GetInstance()->ResetPlayerDataStruct(ph->playerClass);
			ShotTester::GetInstance()->ResetPlayerDataStruct(ph->playerClass);
			SpeedTester::GetInstance()->ResetPlayerDataStruct(ph->playerClass);
		}
	}

	//---------------

	//MathLib_Init( 2.2f, 2.2f, 0.0f, 2 );
	
	g_pCVar->FindVar("nocheatz_instance")->SetValue("1");
	return true;
}
コード例 #4
0
bool CDmxConvertApp::PreInit( )
{
	CreateInterfaceFn factory = GetFactory();
	ConnectTier1Libraries( &factory, 1 );
	ConnectTier2Libraries( &factory, 1 );

	if ( !g_pFullFileSystem || !g_pDataModel )
	{
		Warning( "DMXConvert is missing a required interface!\n" );
		return false;
	}
	return true;
}
コード例 #5
0
ファイル: ifaces.cpp プロジェクト: fwdcp/ExternalExtensions
void Interfaces::Load(CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory) {
	ConnectTier1Libraries(&interfaceFactory, 1);
	ConnectTier2Libraries(&interfaceFactory, 1);
	ConnectTier3Libraries(&interfaceFactory, 1);

	vguiLibrariesAvailable = vgui::VGui_InitInterfacesList("ExternalExtensions", &interfaceFactory, 1);

	pEngineClient = (IVEngineClient *)interfaceFactory(VENGINE_CLIENT_INTERFACE_VERSION, nullptr);
	pEngineTool = (IEngineTool *)interfaceFactory(VENGINETOOL_INTERFACE_VERSION, nullptr);
	pGameEventManager = (IGameEventManager2 *)interfaceFactory(INTERFACEVERSION_GAMEEVENTSMANAGER2, nullptr);
	pModelInfoClient = (IVModelInfoClient *)interfaceFactory(VMODELINFO_CLIENT_INTERFACE_VERSION, nullptr);
	pRenderView = (IVRenderView *)interfaceFactory(VENGINE_RENDERVIEW_INTERFACE_VERSION, nullptr);

	CreateInterfaceFn gameClientFactory;
	pEngineTool->GetClientFactory(gameClientFactory);

	pClientDLL = (IBaseClientDLL*)gameClientFactory(CLIENT_DLL_INTERFACE_VERSION, nullptr);
	pClientEntityList = (IClientEntityList*)gameClientFactory(VCLIENTENTITYLIST_INTERFACE_VERSION, nullptr);

	pSteamAPIContext = new CSteamAPIContext();
	steamLibrariesAvailable = SteamAPI_InitSafe() && pSteamAPIContext->Init();

	g_pEntityList = dynamic_cast<CBaseEntityList *>(Interfaces::pClientEntityList);

	char dll[MAX_PATH];
	bool steam;
	if (FileSystem_GetFileSystemDLLName(dll, sizeof(dll), steam) == FS_OK) {
		CFSLoadModuleInfo fsLoadModuleInfo;
		fsLoadModuleInfo.m_bSteam = steam;
		fsLoadModuleInfo.m_pFileSystemDLLName = dll;
		fsLoadModuleInfo.m_ConnectFactory = interfaceFactory;

		if (FileSystem_LoadFileSystemModule(fsLoadModuleInfo) == FS_OK) {
			CFSMountContentInfo fsMountContentInfo;
			fsMountContentInfo.m_bToolsMode = fsLoadModuleInfo.m_bToolsMode;
			fsMountContentInfo.m_pDirectoryName = fsLoadModuleInfo.m_GameInfoPath;
			fsMountContentInfo.m_pFileSystem = fsLoadModuleInfo.m_pFileSystem;

			if (FileSystem_MountContent(fsMountContentInfo) == FS_OK) {
				CFSSearchPathsInit fsSearchPathsInit;
				fsSearchPathsInit.m_pDirectoryName = fsLoadModuleInfo.m_GameInfoPath;
				fsSearchPathsInit.m_pFileSystem = fsLoadModuleInfo.m_pFileSystem;

				if (FileSystem_LoadSearchPaths(fsSearchPathsInit) == FS_OK) {
					Interfaces::pFileSystem = fsLoadModuleInfo.m_pFileSystem;
				}
			}
		}
	}
}
コード例 #6
0
//---------------------------------------------------------------------------------
// Purpose: called when the plugin is loaded, load the interface we need from the engine
//---------------------------------------------------------------------------------
bool CEmptyServerPlugin::Load(	CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory )
{
	ConnectTier1Libraries( &interfaceFactory, 1 );
	ConnectTier2Libraries( &interfaceFactory, 1 );

	entityinfomanager = (IEntityInfoManager *)gameServerFactory(INTERFACEVERSION_ENTITYINFOMANAGER,NULL);
	if ( !entityinfomanager )
	{
		Warning( "Unable to load entityinfomanager, ignoring\n" ); // this isn't fatal, we just won't be able to access entity data
	}

	playerinfomanager = (IPlayerInfoManager *)gameServerFactory(INTERFACEVERSION_PLAYERINFOMANAGER,NULL);
	if ( !playerinfomanager )
	{
		Warning( "Unable to load playerinfomanager, ignoring\n" ); // this isn't fatal, we just won't be able to access specific player data
	}

	botmanager = (IBotManager *)gameServerFactory(INTERFACEVERSION_PLAYERBOTMANAGER, NULL);
	if ( !botmanager )
	{
		Warning( "Unable to load botcontroller, ignoring\n" ); // this isn't fatal, we just won't be able to access specific bot functions
	}
	gameinfomanager = (IGameInfoManager *)gameServerFactory(INTERFACEVERSION_GAMEINFOMANAGER, NULL);
	if (!gameinfomanager)
	{
		Warning( "Unable to load gameinfomanager, ignoring\n" );
	}

	engine = (IVEngineServer*)interfaceFactory(INTERFACEVERSION_VENGINESERVER, NULL);
	gameeventmanager = (IGameEventManager *)interfaceFactory(INTERFACEVERSION_GAMEEVENTSMANAGER,NULL);
	helpers = (IServerPluginHelpers*)interfaceFactory(INTERFACEVERSION_ISERVERPLUGINHELPERS, NULL);
	enginetrace = (IEngineTrace *)interfaceFactory(INTERFACEVERSION_ENGINETRACE_SERVER,NULL);
	randomStr = (IUniformRandomStream *)interfaceFactory(VENGINE_SERVER_RANDOM_INTERFACE_VERSION, NULL);

	// get the interfaces we want to use
	if(	! ( engine && gameeventmanager && g_pFullFileSystem && helpers && enginetrace && randomStr ) )
	{
		return false; // we require all these interface to function
	}

	if ( playerinfomanager )
	{
		gpGlobals = playerinfomanager->GetGlobalVars();
	}

	MathLib_Init( 2.2f, 2.2f, 0.0f, 2.0f );
	ConVar_Register( 0 );
	return true;
}
コード例 #7
0
ファイル: sp_main.cpp プロジェクト: MrMalina/Source.Python
//-----------------------------------------------------------------------------
// 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;
}
コード例 #8
0
bool CSSServerPlugin::Load(	CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory )
{
	Msg("Loading..\n");
	ConnectTier1Libraries( &interfaceFactory, 1 );

	engine = (IVEngineServer*)interfaceFactory(INTERFACEVERSION_VENGINESERVER, NULL);
	helpers = (IServerPluginHelpers*)interfaceFactory(INTERFACEVERSION_ISERVERPLUGINHELPERS, NULL);
	playerinfomanager = (IPlayerInfoManager *)gameServerFactory(INTERFACEVERSION_PLAYERINFOMANAGER,NULL);

	if(	! ( engine && helpers && playerinfomanager ) )
		return false;

	gpGlobals = playerinfomanager->GetGlobalVars();

	MathLib_Init( 2.2f, 2.2f, 0.0f, 2 );
	ConVar_Register( 0 );

	NetFilter_Load();
	FileFilter_Load();

	return true;
}
コード例 #9
0
//-----------------------------------------------------------------------------
//
// Purpose: Valve entry point called after the Valve DLLs are loaded
// Input  : CreateInterfaceFn factory
// Output : true is everything is good, false otherwise
//
//-----------------------------------------------------------------------------
DLL_EXPORT bool VsMayaConnect( CreateInterfaceFn factory )
{
	ConnectTier1Libraries( &factory, 1 );
	ConnectTier2Libraries( &factory, 1 );
	ConnectTier3Libraries( &factory, 1 );
	if ( !ConnectDataModel( factory ) )
		return false;

	if ( InitDataModel( ) != INIT_OK )
		return false;

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

	if ( !g_pFullFileSystem || !g_pDataModel )
	{
		Warning( "vsDmxIO is missing a required interface!\n" );
		return false;
	}

	// Can't unload this plugin until the libraries have been disconnected
	g_okToUnload = false;

	return true;
}
コード例 #10
0
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
bool CDmxEditApp::PreInit( )
{
	CreateInterfaceFn factory = GetFactory();

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

	ConnectTier1Libraries( &factory, 1 );
	ConnectTier2Libraries( &factory, 1 );
	ConnectTier3Libraries( &factory, 1 );

	if ( !ConnectDataModel( factory ) )
		return false;

	if ( InitDataModel( ) != INIT_OK )
		return false;

	if ( !g_pFullFileSystem || !g_pDataModel )
	{
		Error( "// ERROR: dmxedit is missing a required interface!\n" );
		return false;
	}

	return true;
}
コード例 #11
0
//-----------------------------------------------------------------------------
// Purpose: Initialization
//-----------------------------------------------------------------------------
void CGameUI::Initialize( CreateInterfaceFn factory )
{
	MEM_ALLOC_CREDIT();
	ConnectTier1Libraries( &factory, 1 );
	ConnectTier2Libraries( &factory, 1 );
	ConVar_Register( FCVAR_CLIENTDLL );
	ConnectTier3Libraries( &factory, 1 );

	enginesound = (IEngineSound *)factory(IENGINESOUND_CLIENT_INTERFACE_VERSION, NULL);
	engine = (IVEngineClient *)factory( VENGINE_CLIENT_INTERFACE_VERSION, NULL );
	bik = (IBik*)factory( BIK_INTERFACE_VERSION, NULL );

#ifndef _X360
	SteamAPI_InitSafe();
	steamapicontext->Init();
#endif

	CGameUIConVarRef var( "gameui_xbox" );
	m_bIsConsoleUI = var.IsValid() && var.GetBool();

	vgui::VGui_InitInterfacesList( "GameUI", &factory, 1 );
	vgui::VGui_InitMatSysInterfacesList( "GameUI", &factory, 1 );

	// load localization file
	g_pVGuiLocalize->AddFile( "Resource/gameui_%language%.txt", "GAME", true );

	// load mod info
	ModInfo().LoadCurrentGameInfo();

	// load localization file for kb_act.lst
	g_pVGuiLocalize->AddFile( "Resource/valve_%language%.txt", "GAME", true );

	bool bFailed = false;
	enginevguifuncs = (IEngineVGui *)factory( VENGINE_VGUI_VERSION, NULL );
	enginesurfacefuncs = (vgui::ISurface *)factory(VGUI_SURFACE_INTERFACE_VERSION, NULL);
	gameuifuncs = (IGameUIFuncs *)factory( VENGINE_GAMEUIFUNCS_VERSION, NULL );
	xboxsystem = (IXboxSystem *)factory( XBOXSYSTEM_INTERFACE_VERSION, NULL );
#ifdef _X360
	xonline = (IXOnline *)factory( XONLINE_INTERFACE_VERSION, NULL );
#endif
#ifdef SWARM_DLL
	g_pMatchExtSwarm = ( IMatchExtSwarm * ) factory( IMATCHEXT_SWARM_INTERFACE, NULL );
#endif
#ifdef SDK_DLL
	g_pMatchExtSwarm = ( IMatchExtSwarm * ) factory( IMATCHEXT_SWARM_INTERFACE, NULL );
#endif
	bFailed = !enginesurfacefuncs || !gameuifuncs || !enginevguifuncs ||
		!xboxsystem ||
#ifdef _X360
		!xonline ||
#endif
#ifdef SWARM_DLL
		!g_pMatchExtSwarm ||
#endif
#ifdef SDK_DLL
		!g_pMatchExtSwarm ||
#endif
		!g_pMatchFramework;
	if ( bFailed )
	{
		Error( "CGameUI::Initialize() failed to get necessary interfaces\n" );
	}

	// setup base panel
	UI_BASEMOD_PANEL_CLASS& factoryBasePanel = ConstructUiBaseModPanelClass(); // explicit singleton instantiation

	factoryBasePanel.SetBounds( 0, 0, 640, 480 );
	factoryBasePanel.SetPaintBorderEnabled( false );
	factoryBasePanel.SetPaintBackgroundEnabled( true );
	factoryBasePanel.SetPaintEnabled( true );
	factoryBasePanel.SetVisible( true );

	factoryBasePanel.SetMouseInputEnabled( IsPC() );
	// factoryBasePanel.SetKeyBoardInputEnabled( IsPC() );
	factoryBasePanel.SetKeyBoardInputEnabled( true );

	vgui::VPANEL rootpanel = enginevguifuncs->GetPanel( PANEL_GAMEUIDLL );
	factoryBasePanel.SetParent( rootpanel );
}
コード例 #12
0
ファイル: sp_main.cpp プロジェクト: Doldol/Source.Python
//-----------------------------------------------------------------------------
// 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;
}
コード例 #13
0
ファイル: webspec.cpp プロジェクト: MattMcNam/webspec
//---------------------------------------------------------------------------------
// Purpose: called when the plugin is loaded, load the interface we need from the engine
//---------------------------------------------------------------------------------
bool WebSpecPlugin::Load(	CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory )
{
	ConnectTier1Libraries( &interfaceFactory, 1 );

	playerInfoManager = (IPlayerInfoManager *)gameServerFactory(INTERFACEVERSION_PLAYERINFOMANAGER,NULL);
	if ( !playerInfoManager )
	{
		Warning( "[WebSpec] Unable to load PlayerInfoManager!\n" );
		return false;
	}

	gameEventManager = (IGameEventManager *)interfaceFactory(INTERFACEVERSION_GAMEEVENTSMANAGER,NULL);
	if(	!gameEventManager )
	{
		Warning( "[WebSpec] Unable to load GameEventManager!\n" );
		return false;
	}

	engine = (IVEngineServer *)interfaceFactory(INTERFACEVERSION_VENGINESERVER, NULL);
	if (!engine) {
		Warning("[WebSpec] Unable to load VEngineServer!\n");
		return false;
	}

	serverGameEnts = (IServerGameEnts *)gameServerFactory(INTERFACEVERSION_SERVERGAMEENTS, NULL);
	if (!serverGameEnts) {
		Warning("[WebSpec] Unable to load ServerGameEnts!\n");
		return false;
	}

	serverGameDLL = (IServerGameDLL *)gameServerFactory("ServerGameDLL008", NULL); // ServerGameDLL008 for TF2, not in hl2sdk-ob-valve
	if (!serverGameDLL) {
		return false;
	}

	gameEventManager->AddListener(this, true);

	//Init global variables
	gpGlobals = playerInfoManager->GetGlobalVars();
	ws_teamName[0] = MAKE_STRING("BLU");
	ws_teamName[1] = MAKE_STRING("RED");
	ws_teamReadyState[0] = false;
	ws_teamReadyState[1] = false;
	
	WSOffsets::PrepareOffsets();

	//Init WebSocket server
	lws_context_creation_info *lwsInfo = new lws_context_creation_info();
	lwsInfo->port = wsPort;
	lwsInfo->iface = NULL;
	lwsInfo->protocols = wsProtocols;
	lwsInfo->extensions = libwebsocket_get_internal_extensions();
	lwsInfo->ssl_cert_filepath = NULL;
	lwsInfo->ssl_private_key_filepath = NULL;
	lwsInfo->ssl_ca_filepath = NULL;
	lwsInfo->gid = -1;
	lwsInfo->uid = -1;
	lwsInfo->options = 0;
	lwsInfo->user = NULL;
	lwsInfo->ka_time = 0;

	wsContext = libwebsocket_create_context(lwsInfo);

	if (wsContext == NULL)
		Msg("[WebSpec] failed to init libwebsockets\n");

	//Start WebSpec server
	ws_shouldListen = true;
	WSServerThreadParams_t *params = new WSServerThreadParams_t;
	params->ctx = wsContext;
	CreateSimpleThread( WSServerThread, params );

	g_lastUpdateTime = gpGlobals->curtime;

	//Everything seems ok!
	Msg("%s loaded!\n", PLUGIN_DESCRIPTION);

	//Register cvars
	ConVar_Register( 0 );
	return true;
}
コード例 #14
0
//-----------------------------------------------------------------------------
// PreInit
//-----------------------------------------------------------------------------
bool CIHVTestApp::PreInit( void )
{
	CreateInterfaceFn factory = GetFactory();
	ConnectTier1Libraries( &factory, 1 );

	// Add paths...
	if ( !SetupSearchPaths( NULL, false, true ) )
	{
		Error( "Failed to setup search paths\n" );
		return false;
	}

	const char *pArgVal;
	if ( CommandLine()->CheckParm( "-bench" ) )
	{
		g_BenchMode = true;
	}
	
	if( !g_BenchMode && !CommandLine()->CheckParm( "-i" ) )
	{
		// Set some default parameters for running as a unittest
		g_BenchMode = true;
		g_WindowMode = IsPC() ? true : false;
	}

	if( g_BenchMode )
	{
		if ( CommandLine()->CheckParm( "-i", &pArgVal ) )
		{
			g_BenchRuns[0].pModelName[0] = pArgVal;
		}
	}
	
	if( CommandLine()->CheckParm( "-softwaretl" ) )
	{
		g_SoftwareTL = true;
	}

	// Explicitly in window/fullscreen mode?
	if ( CommandLine()->CheckParm( "-window") )
	{
		g_WindowMode = true;
	}
	else if ( CommandLine()->CheckParm( "-fullscreen" ) )
	{
		g_WindowMode = false;
	}

	/* figure out g_Renderwidth and g_RenderHeight */
	g_RenderWidth = -1;
	g_RenderHeight = -1;

	if( CommandLine()->CheckParm( "-width", &pArgVal ) )
	{
		g_RenderWidth = atoi( pArgVal );
	}
	if( CommandLine()->CheckParm( "-height", &pArgVal ) )
	{
		g_RenderHeight = atoi( pArgVal );
	}

	if( g_RenderWidth == -1 && g_RenderHeight == -1 )
	{
		g_RenderWidth = 640;
		g_RenderHeight = 480;
	}
	else if( g_RenderWidth != -1 && g_RenderHeight == -1 )
	{
		switch( g_RenderWidth )
		{
		case 320:
			g_RenderHeight = 240;
			break;
		case 512:
			g_RenderHeight = 384;
			break;
		case 640:
			g_RenderHeight = 480;
			break;
		case 800:
			g_RenderHeight = 600;
			break;
		case 1024:
			g_RenderHeight = 768;
			break;
		case 1280:
			g_RenderHeight = 1024;
			break;
		case 1600:
			g_RenderHeight = 1200;
			break;
		default:
			DisplayError( "Can't figure out window dimensions!!" );
			exit( -1 );
			break;
		}
	}

	if( g_RenderWidth == -1 || g_RenderHeight == -1 )
	{
		DisplayError( "Can't figure out window dimensions!!" );
		exit( -1 );
	}
	
	int windowWidth, windowHeight;
	CalcWindowSize( g_RenderWidth, g_RenderHeight, &windowWidth, &windowHeight );

	if( !CreateAppWindow( "ihvtest1", windowWidth, windowHeight ) )
	{
		return false;
	}
	return true;
}
コード例 #15
0
//---------------------------------------------------------------------------------
// Purpose: called when the plugin is loaded, load the interface we need from the engine
//---------------------------------------------------------------------------------
bool CEmptyServerPlugin::Load(	CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory )
{
	//bool bSucess = true;
	ConnectTier1Libraries( &interfaceFactory, 1 );
	ConnectTier2Libraries( &interfaceFactory, 1 );

	//g_pFullFileSystem = GetInterface<IFileSystem>( "bin/filesystem_steam.dll", FILESYSTEM_INTERFACE_VERSION );
	g_pFullFileSystem = (IFileSystem *)interfaceFactory(FILESYSTEM_INTERFACE_VERSION, NULL);
//#ifdef WIN32
//	pServerDLL = GetInterface<IServerGameDLL>( "tf/bin/server.dll", INTERFACEVERSION_SERVERGAMEDLL );
//#else
//	pServerDLL = GetInterface<IServerGameDLL>( "tf/bin/server.so", INTERFACEVERSION_SERVERGAMEDLL );
//#endif

	//CSysModule *pClientModule = g_pFullFileSystem->LoadModule("bin/client.dll", "MOD", false);
	//if(!pClientModule)
	//{
	//	Warning("Unable to find client DLL module (are you on a dedicated server?)\n");
	//	return false;
	//}

	//CreateInterfaceFn pfnClientFactory = Sys_GetFactory(pClientModule);
	//if(!interfaceFactory)
	//{
	//	Warning("Unable to retrieve client factory\n");
	//	return false;
	//}

	playerinfomanager = (IPlayerInfoManager *)gameServerFactory(INTERFACEVERSION_PLAYERINFOMANAGER,NULL);
	//if ( !playerinfomanager )
	//{
	//	Warning( "Unable to load playerinfomanager, ignoring\n" ); // this isn't fatal, we just won't be able to access specific player data
	//}

	//botmanager = (IBotManager *)gameServerFactory(INTERFACEVERSION_PLAYERBOTMANAGER, NULL);
	//if ( !botmanager )
	//{
	//	Warning( "Unable to load botcontroller, ignoring\n" ); // this isn't fatal, we just won't be able to access specific bot functions
	//}

	pEngine = (IVEngineServer*)interfaceFactory(INTERFACEVERSION_VENGINESERVER, NULL);
	gameeventmanager = (IGameEventManager2*)interfaceFactory(INTERFACEVERSION_GAMEEVENTSMANAGER2, NULL);
	helpers = (IServerPluginHelpers*)interfaceFactory(INTERFACEVERSION_ISERVERPLUGINHELPERS, NULL);
	enginetrace = (IEngineTrace *)interfaceFactory(INTERFACEVERSION_ENGINETRACE_SERVER,NULL);
	randomStr = (IUniformRandomStream *)interfaceFactory(VENGINE_SERVER_RANDOM_INTERFACE_VERSION, NULL);

	pServerEnts = (IServerGameEnts *)gameServerFactory(INTERFACEVERSION_SERVERGAMEENTS, NULL);
	pServerDLL = (IServerGameDLL *)gameServerFactory(INTERFACEVERSION_SERVERGAMEDLL, NULL);
#ifndef SERVER_BUILD
	pEngineClient = (IVEngineClient *)interfaceFactory(VENGINE_CLIENT_INTERFACE_VERSION, NULL);
	//pEngineClient = UTIL_LoadInterface<IVEngineClient>(interfaceFactory, VENGINE_CLIENT_INTERFACE_VERSION, bSucess);
	//pBaseClientDLL = UTIL_LoadInterface<IBaseClientDLL>(pfnClientFactory, CLIENT_DLL_INTERFACE_VERSION, bSucess);

	pBaseClientDLL = GetInterface<IBaseClientDLL>( "tf/bin/client.dll", CLIENT_DLL_INTERFACE_VERSION );
#endif

	// get the interfaces we want to use
	//if(	! ( pEngine && gameeventmanager && g_pFullFileSystem && helpers && enginetrace && randomStr ) )
	//{
	//	Warning( "Unable to load one of these: engine && gameeventmanager && g_pFullFileSystem && helpers && enginetrace && randomStr\n" );
	//	return false; // we require all these interface to function
	//}

	if ( !ConfirmInterfaces() ){
		return false;
	}

	//if ( playerinfomanager ){
	gpGlobals = playerinfomanager->GetGlobalVars();
	//}
	
	//GetMessageInts();

	plugin_context_init_t init;
	init.pEngine = pEngine;
	init.pPlayerInfoManager = playerinfomanager;
	init.pHelpers = helpers;
	init.pGameEventManager = gameeventmanager;
	init.pServerGameDLL = pServerDLL;

	m_plugin_context.Initialize(init);

	gameeventmanager->AddListener( this, "teamplay_round_stalemate", true );
	gameeventmanager->AddListener( this, "teamplay_round_active", true );		//9:54
	gameeventmanager->AddListener( this, "teamplay_round_win", true );			//end round
	gameeventmanager->AddListener( this, "teamplay_point_captured", true );
	gameeventmanager->AddListener( this, "arena_win_panel", true );
	gameeventmanager->AddListener( this, "teamplay_win_panel", true );			//fix for incorrect round points
	gameeventmanager->AddListener( this, "player_say", true );
	gameeventmanager->AddListener( this, "teamplay_game_over", true );
	gameeventmanager->AddListener( this, "player_changename", true );
	gameeventmanager->AddListener( this, "player_team", true );
	gameeventmanager->AddListener( this, "tf_game_over", true );
	//gameeventmanager->AddListener( this, "teamplay_broadcast_audio", true );

	m_SizzlingMatches.Load(m_plugin_context);
	m_SizzlingMatches.SM_GetPropOffsets();
	m_SizzlingMatches.SM_SetEventUpdateInterval( 3.0f );
	m_SizzlingMatches.SM_LoadCurrentPlayers();

	//pEngine->ServerCommand( "con_logfile sizzmatches.txt\n" );
	//Name: 	player_changename
	//Structure: 	
	//short 	userid 	user ID on server
	//string 	oldname 	players old (current) name
	//string 	newname 	players new name 

	//Name: 	player_chat						// doesn't work
	//Structure: 	
	//bool 	teamonly 	true if team only chat
	//short 	userid 	chatting player
	//string 	text 	chat text 

	//Name: 	player_say
	//Structure: 	
	//short 	userid 	chatting player
	//string 	text 	chat text 

	MathLib_Init( 2.2f, 2.2f, 0.0f, 2 );
	ConVar_Register( 0 );
	return true;
}