bool checkext_hook(char *filename)
{
	if(filename == NULL)
		return 0;

	if ( cvar_showcheck.GetBool() )
		Msg("Checking file %s\n", filename );

	int safe = checkext_trampoline(filename);
	if(!safe)
		return 0;

	INetworkStringTable *downloads = netstringtables->FindTable("downloadables");
	if(downloads == NULL)
	{
		Msg("Missing downloadables string table\n");
		return 0;
	}
	
	int len = strlen(filename);
	int index = downloads->FindStringIndex(filename);

	if(index == INVALID_STRING_INDEX && (len > 5 && strncmp(filename, "maps/", 5) == 0))
	{
		for(int i = 0; i < len; i++)
		{
			if(filename[i] == '/')
				filename[i] = '\\';
		}

		index = downloads->FindStringIndex(filename);
	}

	if(index != INVALID_STRING_INDEX)
	{
		return safe;
	}

	if(len == 22 && strncmp(filename, "downloads/", 10) == 0 && strncmp(filename + len - 4, ".dat", 4) == 0)
	{
		return safe;
	}

	Msg("Blocking download: %s\n", filename);
	return 0;
}
Exemple #2
0
bool AddToDownloadables( const char *file )
{
	INetworkStringTable *pDownloadablesTable = networkstringtable->FindTable( "downloadables" );
	// Actually, it would be desirable to add the last line to
	// ServerActivate and store the pointer, so each time you
	// add a download you dont have to find it again.
	if ( pDownloadablesTable )
	{
		bool save = engine->LockNetworkStringTables( false );
		int iRet = pDownloadablesTable->FindStringIndex( file );
		if ( iRet == INVALID_STRING_INDEX )
		{
			pDownloadablesTable->AddString( CBaseEntity::IsServer(), file, sizeof( file ) + 1 );
			engine->LockNetworkStringTables( save );
		}
		else
		{
			DevMsg( "AddDownload: Multiple download of \"%s\"", file );
		}
		return true;
	}
	DevMsg("Table downloadables not found!\n");
	return false;
}