|
| 1 | +#include <cstdlib> |
| 2 | +#include "eiface.h" |
| 3 | +#include "icvar.h" |
| 4 | +#include "tier1/iconvar.h" |
| 5 | +#include "tier1/convar.h" |
| 6 | + |
| 7 | +// memdbgon must be the last include file in a .cpp file!!! |
| 8 | +//#include "tier0/memdbgon.h" |
| 9 | + |
| 10 | +class RecordingHelpers: public IServerPluginCallbacks |
| 11 | +{ |
| 12 | +public: |
| 13 | + // IServerPluginCallbacks methods |
| 14 | + virtual bool Load( CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory ); |
| 15 | + virtual void Unload( void ); |
| 16 | + virtual void Pause( void ); |
| 17 | + virtual void UnPause( void ); |
| 18 | + virtual const char *GetPluginDescription( void ); |
| 19 | + virtual void LevelInit( char const *pMapName ); |
| 20 | + virtual void ServerActivate( edict_t *pEdictList, int edictCount, int clientMax ); |
| 21 | + virtual void GameFrame( bool simulating ); |
| 22 | + virtual void LevelShutdown( void ); |
| 23 | + virtual void ClientActive( edict_t *pEntity ); |
| 24 | + virtual void ClientFullyConnect( edict_t *pEntity ); |
| 25 | + virtual void ClientDisconnect( edict_t *pEntity ); |
| 26 | + virtual void ClientPutInServer( edict_t *pEntity, char const *playername ); |
| 27 | + virtual void SetCommandClient( int index ); |
| 28 | + virtual void ClientSettingsChanged( edict_t *pEdict ); |
| 29 | + virtual PLUGIN_RESULT ClientConnect( bool *bAllowConnect, edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen ); |
| 30 | + virtual PLUGIN_RESULT ClientCommand( edict_t *pEntity, const CCommand &args ); |
| 31 | + virtual PLUGIN_RESULT NetworkIDValidated( const char *pszUserName, const char *pszNetworkID ); |
| 32 | + virtual void OnQueryCvarValueFinished( QueryCvarCookie_t iCookie, edict_t *pPlayerEntity, EQueryCvarValueStatus eStatus, const char *pCvarName, const char *pCvarValue ); |
| 33 | + |
| 34 | + // added with version 3 of the interface. |
| 35 | + virtual void OnEdictAllocated( edict_t *edict ); |
| 36 | + virtual void OnEdictFreed( const edict_t *edict ); |
| 37 | + |
| 38 | +}; |
| 39 | + |
| 40 | + |
| 41 | +RecordingHelpers g_RecordingHelpersPlugin; |
| 42 | +EXPOSE_SINGLE_INTERFACE_GLOBALVAR(RecordingHelpers, IServerPluginCallbacks, INTERFACEVERSION_ISERVERPLUGINCALLBACKS, g_RecordingHelpersPlugin ); |
| 43 | + |
| 44 | +ICvar * g_pCvar = NULL; |
| 45 | + |
| 46 | + |
| 47 | +//--------------------------------------------------------------------------------- |
| 48 | +// Purpose: called once per server frame, do recurring work here (like checking for timeouts) |
| 49 | +//--------------------------------------------------------------------------------- |
| 50 | +void RecordingHelpers::GameFrame( bool simulating ) |
| 51 | +{ |
| 52 | +} |
| 53 | + |
| 54 | +//--------------------------------------------------------------------------------- |
| 55 | +// Purpose: called when the plugin is loaded, load the interface we need from the engine |
| 56 | +//--------------------------------------------------------------------------------- |
| 57 | +bool RecordingHelpers::Load( CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory ) |
| 58 | +{ |
| 59 | + g_pCvar = reinterpret_cast<ICvar *>(interfaceFactory(CVAR_INTERFACE_VERSION,NULL)); |
| 60 | + |
| 61 | + if(g_pCvar == NULL) |
| 62 | + { |
| 63 | + Warning("RecordingHelpers: Failed to get Cvar interface.\n"); |
| 64 | + return false; |
| 65 | + } |
| 66 | + |
| 67 | + // Remove all devonly flags |
| 68 | + ICvar::Iterator iter(g_pCvar); |
| 69 | + for ( iter.SetFirst() ; iter.IsValid() ; iter.Next() ) |
| 70 | + { |
| 71 | + ConCommandBase *cmd = iter.Get(); |
| 72 | + cmd->RemoveFlags(FCVAR_DEVELOPMENTONLY); |
| 73 | + } |
| 74 | + return true; |
| 75 | +} |
| 76 | + |
| 77 | +//--------------------------------------------------------------------------------- |
| 78 | +// Purpose: called when the plugin is unloaded (turned off) |
| 79 | +//--------------------------------------------------------------------------------- |
| 80 | +void RecordingHelpers::Unload( void ) |
| 81 | +{ |
| 82 | +} |
| 83 | + |
| 84 | +//--------------------------------------------------------------------------------- |
| 85 | +// Purpose: called when the plugin is paused (i.e should stop running but isn't unloaded) |
| 86 | +//--------------------------------------------------------------------------------- |
| 87 | +void RecordingHelpers::Pause( void ) |
| 88 | +{ |
| 89 | +} |
| 90 | + |
| 91 | +//--------------------------------------------------------------------------------- |
| 92 | +// Purpose: called when the plugin is unpaused (i.e should start executing again) |
| 93 | +//--------------------------------------------------------------------------------- |
| 94 | +void RecordingHelpers::UnPause( void ) |
| 95 | +{ |
| 96 | +} |
| 97 | + |
| 98 | +//--------------------------------------------------------------------------------- |
| 99 | +// Purpose: the name of this plugin, returned in "plugin_print" command |
| 100 | +//--------------------------------------------------------------------------------- |
| 101 | +const char *RecordingHelpers::GetPluginDescription( void ) |
| 102 | +{ |
| 103 | + return "RecordingHelpers 0.1, ProdigySim"; |
| 104 | +} |
| 105 | + |
| 106 | +//--------------------------------------------------------------------------------- |
| 107 | +// Purpose: called on level start |
| 108 | +//--------------------------------------------------------------------------------- |
| 109 | +void RecordingHelpers::LevelInit( char const *pMapName ) |
| 110 | +{ |
| 111 | +} |
| 112 | + |
| 113 | +//--------------------------------------------------------------------------------- |
| 114 | +// Purpose: called on level start, when the server is ready to accept client connections |
| 115 | +// edictCount is the number of entities in the level, clientMax is the max client count |
| 116 | +//--------------------------------------------------------------------------------- |
| 117 | +void RecordingHelpers::ServerActivate( edict_t *pEdictList, int edictCount, int clientMax ) |
| 118 | +{ |
| 119 | +} |
| 120 | + |
| 121 | +//--------------------------------------------------------------------------------- |
| 122 | +// Purpose: called on level end (as the server is shutting down or going to a new map) |
| 123 | +//--------------------------------------------------------------------------------- |
| 124 | +void RecordingHelpers::LevelShutdown( void ) // !!!!this can get called multiple times per map change |
| 125 | +{ |
| 126 | +} |
| 127 | + |
| 128 | +//--------------------------------------------------------------------------------- |
| 129 | +// Purpose: called when a client spawns into a server (i.e as they begin to play) |
| 130 | +//--------------------------------------------------------------------------------- |
| 131 | +void RecordingHelpers::ClientActive( edict_t *pEntity ) |
| 132 | +{ |
| 133 | +} |
| 134 | + |
| 135 | +void RecordingHelpers::ClientFullyConnect( edict_t *pEntity ) |
| 136 | +{ |
| 137 | +} |
| 138 | + |
| 139 | +//--------------------------------------------------------------------------------- |
| 140 | +// Purpose: called when a client leaves a server (or is timed out) |
| 141 | +//--------------------------------------------------------------------------------- |
| 142 | +void RecordingHelpers::ClientDisconnect( edict_t *pEntity ) |
| 143 | +{ |
| 144 | +} |
| 145 | + |
| 146 | +//--------------------------------------------------------------------------------- |
| 147 | +// Purpose: called on |
| 148 | +//--------------------------------------------------------------------------------- |
| 149 | +void RecordingHelpers::ClientPutInServer( edict_t *pEntity, char const *playername ) |
| 150 | +{ |
| 151 | +} |
| 152 | + |
| 153 | +//--------------------------------------------------------------------------------- |
| 154 | +// Purpose: called on level start |
| 155 | +//--------------------------------------------------------------------------------- |
| 156 | +void RecordingHelpers::SetCommandClient( int index ) |
| 157 | +{ |
| 158 | +} |
| 159 | + |
| 160 | +//--------------------------------------------------------------------------------- |
| 161 | +// Purpose: called on level start |
| 162 | +//--------------------------------------------------------------------------------- |
| 163 | +void RecordingHelpers::ClientSettingsChanged( edict_t *pEdict ) |
| 164 | +{ |
| 165 | +} |
| 166 | + |
| 167 | +//--------------------------------------------------------------------------------- |
| 168 | +// Purpose: called when a client joins a server |
| 169 | +//--------------------------------------------------------------------------------- |
| 170 | +PLUGIN_RESULT RecordingHelpers::ClientConnect( bool *bAllowConnect, edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen ) |
| 171 | +{ |
| 172 | + return PLUGIN_CONTINUE; |
| 173 | +} |
| 174 | + |
| 175 | +//--------------------------------------------------------------------------------- |
| 176 | +// Purpose: called when a client types in a command (only a subset of commands however, not CON_COMMAND's) |
| 177 | +//--------------------------------------------------------------------------------- |
| 178 | +PLUGIN_RESULT RecordingHelpers::ClientCommand( edict_t *pEntity, const CCommand &args ) |
| 179 | +{ |
| 180 | + return PLUGIN_CONTINUE; |
| 181 | +} |
| 182 | + |
| 183 | +//--------------------------------------------------------------------------------- |
| 184 | +// Purpose: called when a client is authenticated |
| 185 | +//--------------------------------------------------------------------------------- |
| 186 | +PLUGIN_RESULT RecordingHelpers::NetworkIDValidated( const char *pszUserName, const char *pszNetworkID ) |
| 187 | +{ |
| 188 | + return PLUGIN_CONTINUE; |
| 189 | +} |
| 190 | + |
| 191 | +//--------------------------------------------------------------------------------- |
| 192 | +// Purpose: called when a cvar value query is finished |
| 193 | +//--------------------------------------------------------------------------------- |
| 194 | +void RecordingHelpers::OnQueryCvarValueFinished( QueryCvarCookie_t iCookie, edict_t *pPlayerEntity, EQueryCvarValueStatus eStatus, const char *pCvarName, const char *pCvarValue ) |
| 195 | +{ |
| 196 | +} |
| 197 | +void RecordingHelpers::OnEdictAllocated( edict_t *edict ) |
| 198 | +{ |
| 199 | +} |
| 200 | +void RecordingHelpers::OnEdictFreed( const edict_t *edict ) |
| 201 | +{ |
| 202 | +} |
0 commit comments