Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: A higher level link library for general use in the game and tools.
  4. //
  5. //===========================================================================//
  6. #include <tier1/tier1.h>
  7. #include "tier0/dbg.h"
  8. #include "vstdlib/iprocessutils.h"
  9. #include "icvar.h"
  10. //-----------------------------------------------------------------------------
  11. // These tier1 libraries must be set by any users of this library.
  12. // They can be set by calling ConnectTier1Libraries or InitDefaultFileSystem.
  13. // It is hoped that setting this, and using this library will be the common mechanism for
  14. // allowing link libraries to access tier1 library interfaces
  15. //-----------------------------------------------------------------------------
  16. ICvar *cvar = 0;
  17. ICvar *g_pCVar = 0;
  18. IProcessUtils *g_pProcessUtils = 0;
  19. static bool s_bConnected = false;
  20. // for utlsortvector.h
  21. #ifndef _WIN32
  22. void *g_pUtlSortVectorQSortContext = NULL;
  23. #endif
  24. //-----------------------------------------------------------------------------
  25. // Call this to connect to all tier 1 libraries.
  26. // It's up to the caller to check the globals it cares about to see if ones are missing
  27. //-----------------------------------------------------------------------------
  28. void ConnectTier1Libraries( CreateInterfaceFn *pFactoryList, int nFactoryCount )
  29. {
  30. // Don't connect twice..
  31. if ( s_bConnected )
  32. return;
  33. s_bConnected = true;
  34. for ( int i = 0; i < nFactoryCount; ++i )
  35. {
  36. if ( !g_pCVar )
  37. {
  38. cvar = g_pCVar = ( ICvar * )pFactoryList[i]( CVAR_INTERFACE_VERSION, NULL );
  39. }
  40. if ( !g_pProcessUtils )
  41. {
  42. g_pProcessUtils = ( IProcessUtils * )pFactoryList[i]( PROCESS_UTILS_INTERFACE_VERSION, NULL );
  43. }
  44. }
  45. }
  46. void DisconnectTier1Libraries()
  47. {
  48. if ( !s_bConnected )
  49. return;
  50. g_pCVar = cvar = 0;
  51. g_pProcessUtils = NULL;
  52. s_bConnected = false;
  53. }