stub_mm/stub_mm.cpp
author David Anderson <dvander@alliedmods.net>
Sun Oct 07 03:12:19 2007 +0000 (2007-10-07)
changeset 379 e8a3f2617a3e
parent 378 771bb7db49de
child 394 ba7a29343ea1
permissions -rw-r--r--
initial import of unfinished new sample plugin
this one is more based on valve's sample...
     1 /**
     2  * vim: set ts=4 :
     3  * ======================================================
     4  * Metamod:Source Stub 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 stub plugin is public domain.
    13  *
    14  * Version: $Id$
    15  */
    16 
    17 #include <stdio.h>
    18 #include "stub_mm.h"
    19 
    20 SH_DECL_HOOK3_void(IServerGameDLL, ServerActivate, SH_NOATTRIB, 0, edict_t *, int, int);
    21 
    22 StubPlugin g_StubPlugin;
    23 IServerGameDLL *server = NULL;
    24 int hidServerActivate = 0;
    25 
    26 PLUGIN_EXPOSE(StubPlugin, g_StubPlugin);
    27 bool StubPlugin::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
    28 {
    29 	PLUGIN_SAVEVARS();
    30 
    31 	GET_V_IFACE_ANY(GetServerFactory, server, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
    32 
    33 	hidServerActivate = SH_ADD_HOOK(IServerGameDLL, ServerActivate, server, SH_STATIC(Hook_ServerActivate), true);
    34 
    35 	return true;
    36 }
    37 
    38 bool StubPlugin::Unload(char *error, size_t maxlen)
    39 {
    40 	if (hidServerActivate != 0)
    41 	{
    42 		SH_REMOVE_HOOK_ID(hidServerActivate);
    43 	}
    44 
    45 	return true;
    46 }
    47 
    48 void Hook_ServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
    49 {
    50 	META_LOG(g_PLAPI, "ServerActivate() called: edictCount = %d, clientMax = %d", edictCount, clientMax);
    51 }
    52 
    53 void StubPlugin::AllPluginsLoaded()
    54 {
    55 	/* This is where we'd do stuff that relies on the mod or other plugins 
    56 	 * being initialized (for example, cvars added and events registered).
    57 	 */
    58 }
    59 
    60 bool StubPlugin::Pause(char *error, size_t maxlen)
    61 {
    62 	return true;
    63 }
    64 
    65 bool StubPlugin::Unpause(char *error, size_t maxlen)
    66 {
    67 	return true;
    68 }
    69 
    70 const char *StubPlugin::GetLicense()
    71 {
    72 	return "Public Domain";
    73 }
    74 
    75 const char *StubPlugin::GetVersion()
    76 {
    77 	return "1.0.0.0";
    78 }
    79 
    80 const char *StubPlugin::GetDate()
    81 {
    82 	return __DATE__;
    83 }
    84 
    85 const char *StubPlugin::GetLogTag()
    86 {
    87 	return "STUB";
    88 }
    89 
    90 const char *StubPlugin::GetAuthor()
    91 {
    92 	return "AlliedModders LLC";
    93 }
    94 
    95 const char *StubPlugin::GetDescription()
    96 {
    97 	return "Sample empty plugin";
    98 }
    99 
   100 const char *StubPlugin::GetName()
   101 {
   102 	return "Stub Plugin";
   103 }
   104 
   105 const char *StubPlugin::GetURL()
   106 {
   107 	return "http://www.sourcemm.net/";
   108 }