Counter Strike : Global Offensive Source Code
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.

118 lines
4.1 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #ifndef SV_SERVERPLUGIN_H
  9. #define SV_SERVERPLUGIN_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "eiface.h"
  14. #include "engine/iserverplugin.h"
  15. //---------------------------------------------------------------------------------
  16. // Purpose: a single plugin
  17. //---------------------------------------------------------------------------------
  18. class CPlugin
  19. {
  20. public:
  21. CPlugin();
  22. ~CPlugin();
  23. const char *GetName();
  24. bool Load( const char *fileName );
  25. void Unload();
  26. void Disable( bool state );
  27. bool IsDisabled() { return m_bDisable; }
  28. int GetPluginInterfaceVersion() const { return m_iPluginInterfaceVersion; }
  29. IServerPluginCallbacks *GetCallback();
  30. private:
  31. void SetName( const char *name );
  32. char m_szName[128];
  33. bool m_bDisable;
  34. IServerPluginCallbacks *m_pPlugin;
  35. int m_iPluginInterfaceVersion; // Tells if we got INTERFACEVERSION_ISERVERPLUGINCALLBACKS or an older version.
  36. CSysModule *m_pPluginModule;
  37. };
  38. //---------------------------------------------------------------------------------
  39. // Purpose: implenents passthroughs for plugins and their special helper functions
  40. //---------------------------------------------------------------------------------
  41. class CServerPlugin : public IServerPluginHelpers
  42. {
  43. public:
  44. CServerPlugin();
  45. ~CServerPlugin();
  46. // management functions
  47. void LoadPlugins();
  48. void UnloadPlugins();
  49. bool UnloadPlugin( int index );
  50. bool LoadPlugin( const char *fileName );
  51. void DisablePlugins();
  52. void DisablePlugin( int index );
  53. void EnablePlugins();
  54. void EnablePlugin( int index );
  55. void PrintDetails();
  56. // multiplex the passthroughs
  57. virtual void LevelInit( char const *pMapName,
  58. char const *pMapEntities, char const *pOldLevel,
  59. char const *pLandmarkName, bool loadGame, bool background );
  60. virtual void ServerActivate( edict_t *pEdictList, int edictCount, int clientMax );
  61. virtual void GameFrame( bool simulating );
  62. virtual void LevelShutdown( void );
  63. virtual void ClientActive( edict_t *pEntity, bool bLoadGame );
  64. virtual void ClientFullyConnect( edict_t *pEntity );
  65. virtual void ClientDisconnect( edict_t *pEntity );
  66. virtual void ClientPutInServer( edict_t *pEntity, char const *playername );
  67. virtual void SetCommandClient( int index );
  68. virtual void ClientSettingsChanged( edict_t *pEdict );
  69. virtual bool ClientConnect( edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen );
  70. virtual void ClientCommand( edict_t *pEntity, const CCommand &args );
  71. virtual void NetworkIDValidated( const char *pszUserName, const char *pszNetworkID );
  72. virtual void OnQueryCvarValueFinished( QueryCvarCookie_t iCookie, edict_t *pPlayerEntity, EQueryCvarValueStatus eStatus, const char *pCvarName, const char *pCvarValue );
  73. // implement helpers
  74. virtual void CreateMessage( edict_t *pEntity, DIALOG_TYPE type, KeyValues *data, IServerPluginCallbacks *plugin );
  75. virtual void ClientCommand( edict_t *pEntity, const char *cmd );
  76. virtual QueryCvarCookie_t StartQueryCvarValue( edict_t *pEntity, const char *pName );
  77. private:
  78. CUtlVector<CPlugin *> m_Plugins;
  79. IPluginHelpersCheck *m_PluginHelperCheck;
  80. public:
  81. //New plugin interface callbacks
  82. virtual void OnEdictAllocated( edict_t *edict );
  83. virtual void OnEdictFreed( const edict_t *edict );
  84. // Allow plugins to validate and configure network encryption keys
  85. virtual bool BNetworkCryptKeyCheckRequired( uint32 unFromIP, uint16 usFromPort, uint32 unAccountIdProvidedByClient,
  86. bool bClientWantsToUseCryptKey );
  87. virtual bool BNetworkCryptKeyValidate( uint32 unFromIP, uint16 usFromPort, uint32 unAccountIdProvidedByClient,
  88. int nEncryptionKeyIndexFromClient, int numEncryptedBytesFromClient, byte *pbEncryptedBufferFromClient,
  89. byte *pbPlainTextKeyForNetchan );
  90. };
  91. extern CServerPlugin *g_pServerPluginHandler;
  92. class IClient;
  93. QueryCvarCookie_t SendCvarValueQueryToClient( IClient *client, const char *pCvarName, bool bPluginQuery );
  94. #endif //SV_SERVERPLUGIN_H