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.

63 lines
1.8 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef SERVERBENCHMARK_BASE_H
  7. #define SERVERBENCHMARK_BASE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. // The base server code calls into this.
  12. class IServerBenchmark
  13. {
  14. public:
  15. virtual bool StartBenchmark() = 0;
  16. virtual void UpdateBenchmark() = 0;
  17. virtual bool IsBenchmarkRunning() = 0;
  18. virtual bool IsLocalBenchmarkPlayer( CBasePlayer *pPlayer ) = 0;
  19. // Game-specific benchmark code should use this.
  20. virtual int RandomInt( int nMin, int nMax ) = 0;
  21. virtual float RandomFloat( float flMin, float flMax ) = 0;
  22. virtual int GetTickOffset() = 0;
  23. };
  24. extern IServerBenchmark *g_pServerBenchmark;
  25. //
  26. // Each game can derive from this to hook into the server benchmark.
  27. //
  28. // Hooks should always use g_pServerBenchmark->RandomInt/Float to get random numbers
  29. // so the benchmark is deterministic.
  30. //
  31. // If they use an absolute tick number for anything, then they should also call g_pServerBenchmark->GetTickOffset()
  32. // to get a tick count since the start of the benchmark instead of looking at gpGlobals->tickcount.
  33. //
  34. class CServerBenchmarkHook
  35. {
  36. public:
  37. CServerBenchmarkHook();
  38. virtual void StartBenchmark() {}
  39. virtual void UpdateBenchmark() {}
  40. // Give a list of model names that can be spawned in for physics props during the simulation.
  41. virtual void GetPhysicsModelNames( CUtlVector<char*> &modelNames ) = 0;
  42. // The benchmark will call this to create a bot each time it wants to create a player.
  43. // If you want to manage the bots yourself, you can return NULL here.
  44. virtual CBasePlayer* CreateBot() = 0;
  45. private:
  46. friend class CServerBenchmark;
  47. static CServerBenchmarkHook *s_pBenchmarkHook; // There can be only one!!
  48. };
  49. #endif // SERVERBENCHMARK_BASE_H