sample_mm/sample_mm.h
author David Anderson <dvander@alliedmods.net>
Sat Oct 15 22:16:50 2011 -0700 (2011-10-15)
changeset 767 fd3ff8d792ce
parent 678 c676a9ce0320
permissions -rw-r--r--
Fix page protection bug causing a rare startup crash (bug 5133, r=fyren).
     1 /**
     2  * vim: set ts=4 sw=4 tw=99 noet :
     3  * ======================================================
     4  * Metamod:Source Sample Plugin
     5  * Written by AlliedModders LLC.
     6  * ======================================================
     7  *
     8  * This software is provided 'as-is', without any express or implied warranty.
     9  * In no event will the authors be held liable for any damages arising from 
    10  * the use of this software.
    11  *
    12  * This sample plugin is public domain.
    13  */
    14 
    15 #ifndef _INCLUDE_METAMOD_SOURCE_STUB_PLUGIN_H_
    16 #define _INCLUDE_METAMOD_SOURCE_STUB_PLUGIN_H_
    17 
    18 #include <ISmmPlugin.h>
    19 #include <igameevents.h>
    20 #include <iplayerinfo.h>
    21 #include <sh_vector.h>
    22 #include "engine_wrappers.h"
    23 
    24 #if defined WIN32 && !defined snprintf
    25 #define snprintf _snprintf
    26 #endif
    27 
    28 class SamplePlugin : public ISmmPlugin, public IMetamodListener
    29 {
    30 public:
    31 	bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late);
    32 	bool Unload(char *error, size_t maxlen);
    33 	bool Pause(char *error, size_t maxlen);
    34 	bool Unpause(char *error, size_t maxlen);
    35 	void AllPluginsLoaded();
    36 public: //IMetamodListener stuff
    37 	void OnVSPListening(IServerPluginCallbacks *iface);
    38 public: //hooks
    39 	void Hook_ServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
    40 	bool Hook_LevelInit(const char *pMapName,
    41 		char const *pMapEntities,
    42 		char const *pOldLevel,
    43 		char const *pLandmarkName,
    44 		bool loadGame,
    45 		bool background);
    46 	void Hook_GameFrame(bool simulating);
    47 	void Hook_LevelShutdown(void);
    48 	void Hook_ClientActive(edict_t *pEntity, bool bLoadGame);
    49 	void Hook_ClientDisconnect(edict_t *pEntity);
    50 	void Hook_ClientPutInServer(edict_t *pEntity, char const *playername);
    51 	void Hook_SetCommandClient(int index);
    52 	void Hook_ClientSettingsChanged(edict_t *pEdict);
    53 	bool Hook_ClientConnect(edict_t *pEntity, 
    54 		const char *pszName,
    55 		const char *pszAddress,
    56 		char *reject,
    57 		int maxrejectlen);
    58 #if SOURCE_ENGINE >= SE_ORANGEBOX
    59 	void Hook_ClientCommand(edict_t *pEntity, const CCommand &args);
    60 #else
    61 	void Hook_ClientCommand(edict_t *pEntity);
    62 #endif
    63 public:
    64 	const char *GetAuthor();
    65 	const char *GetName();
    66 	const char *GetDescription();
    67 	const char *GetURL();
    68 	const char *GetLicense();
    69 	const char *GetVersion();
    70 	const char *GetDate();
    71 	const char *GetLogTag();
    72 };
    73 
    74 extern SamplePlugin g_SamplePlugin;
    75 
    76 PLUGIN_GLOBALVARS();
    77 
    78 #endif //_INCLUDE_METAMOD_SOURCE_STUB_PLUGIN_H_