diff options
| author | Joe Ludwig <[email protected]> | 2013-06-26 15:22:04 -0700 |
|---|---|---|
| committer | Joe Ludwig <[email protected]> | 2013-06-26 15:22:04 -0700 |
| commit | 39ed87570bdb2f86969d4be821c94b722dc71179 (patch) | |
| tree | abc53757f75f40c80278e87650ea92808274aa59 /mp/src/game/server/serverbenchmark_base.h | |
| download | source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.tar.xz source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.zip | |
First version of the SOurce SDK 2013
Diffstat (limited to 'mp/src/game/server/serverbenchmark_base.h')
| -rw-r--r-- | mp/src/game/server/serverbenchmark_base.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/mp/src/game/server/serverbenchmark_base.h b/mp/src/game/server/serverbenchmark_base.h new file mode 100644 index 00000000..0a9f6479 --- /dev/null +++ b/mp/src/game/server/serverbenchmark_base.h @@ -0,0 +1,65 @@ +//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================
+
+#ifndef SERVERBENCHMARK_BASE_H
+#define SERVERBENCHMARK_BASE_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+
+// The base server code calls into this.
+class IServerBenchmark
+{
+public:
+ virtual bool StartBenchmark() = 0;
+ virtual void UpdateBenchmark() = 0;
+ virtual void EndBenchmark() = 0;
+
+ virtual bool IsBenchmarkRunning() = 0;
+ virtual bool IsLocalBenchmarkPlayer( CBasePlayer *pPlayer ) = 0;
+
+ // Game-specific benchmark code should use this.
+ virtual int RandomInt( int nMin, int nMax ) = 0;
+ virtual float RandomFloat( float flMin, float flMax ) = 0;
+ virtual int GetTickOffset() = 0;
+};
+
+extern IServerBenchmark *g_pServerBenchmark;
+
+
+//
+// Each game can derive from this to hook into the server benchmark.
+//
+// Hooks should always use g_pServerBenchmark->RandomInt/Float to get random numbers
+// so the benchmark is deterministic.
+//
+// If they use an absolute tick number for anything, then they should also call g_pServerBenchmark->GetTickOffset()
+// to get a tick count since the start of the benchmark instead of looking at gpGlobals->tickcount.
+//
+class CServerBenchmarkHook
+{
+public:
+ CServerBenchmarkHook();
+
+ virtual void StartBenchmark() {}
+ virtual void UpdateBenchmark() {}
+ virtual void EndBenchmark() {}
+
+ // Give a list of model names that can be spawned in for physics props during the simulation.
+ virtual void GetPhysicsModelNames( CUtlVector<char*> &modelNames ) = 0;
+
+ // The benchmark will call this to create a bot each time it wants to create a player.
+ // If you want to manage the bots yourself, you can return NULL here.
+ virtual CBasePlayer* CreateBot() = 0;
+
+private:
+ friend class CServerBenchmark;
+ static CServerBenchmarkHook *s_pBenchmarkHook; // There can be only one!!
+};
+
+
+#endif // SERVERBENCHMARK_BASE_H
|