public/mms_sample_ext/stub_mm.cpp
author Scott Ehlert <ds@alliedmods.net>
Fri Apr 11 17:16:36 2008 +0000 (2008-04-11)
changeset 1990 de135d1f05b1
parent 1952 b7aa2b626807
child 3819 d17aed3d46bf
permissions -rw-r--r--
Added more missing svn:keywords properties to some files (this should be the last of them before I never have to do this again)
Moved sm_memtable files in sqlite extension to sdk directory (to be consistent with topmenus)
Some extension source files had an incorrect extension name in their headers
ds@1952
     1
/**
ds@1952
     2
 * vim: set ts=4 :
ds@1952
     3
 * ======================================================
ds@1952
     4
 * Metamod:Source Stub Plugin
ds@1952
     5
 * Written by AlliedModders LLC.
ds@1952
     6
 * ======================================================
ds@1952
     7
 *
ds@1952
     8
 * This software is provided 'as-is', without any express or implied warranty.
ds@1952
     9
 * In no event will the authors be held liable for any damages arising from 
ds@1952
    10
 * the use of this software.
ds@1952
    11
 *
ds@1952
    12
 * This stub plugin is public domain.
ds@1952
    13
 *
ds@1990
    14
 * Version: $Id$
ds@1952
    15
 */
ds@1952
    16
ds@1952
    17
#include <stdio.h>
ds@1952
    18
#include "stub_mm.h"
ds@1952
    19
#include "stub_util.h"
ds@1952
    20
#include "sm_ext.h"
ds@1952
    21
ds@1952
    22
SH_DECL_HOOK3_void(IServerGameDLL, ServerActivate, SH_NOATTRIB, 0, edict_t *, int, int);
ds@1952
    23
ds@1952
    24
StubPlugin g_StubPlugin;
ds@1952
    25
IVEngineServer *engine = NULL;
ds@1952
    26
IServerGameDLL *server = NULL;
ds@1952
    27
ISmmPlugin *mmsplugin = &g_StubPlugin;
ds@1952
    28
ds@1952
    29
PLUGIN_EXPOSE(StubPlugin, g_StubPlugin);
ds@1952
    30
bool StubPlugin::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
ds@1952
    31
{
ds@1952
    32
	PLUGIN_SAVEVARS();
ds@1952
    33
ds@1952
    34
#if defined METAMOD_PLAPI_VERSION
ds@1952
    35
	GET_V_IFACE_ANY(GetServerFactory, server, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
ds@1952
    36
	GET_V_IFACE_ANY(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
ds@1952
    37
#else
ds@1952
    38
	GET_V_IFACE_ANY(serverFactory, server, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
ds@1952
    39
	GET_V_IFACE_ANY(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
ds@1952
    40
#endif
ds@1952
    41
ds@1952
    42
	SH_ADD_HOOK_STATICFUNC(IServerGameDLL, ServerActivate, server, Hook_ServerActivate, true);
ds@1952
    43
ds@1952
    44
	ismm->AddListener(this, this);
ds@1952
    45
ds@1952
    46
	return true;
ds@1952
    47
}
ds@1952
    48
ds@1952
    49
bool StubPlugin::Unload(char *error, size_t maxlen)
ds@1952
    50
{
ds@1952
    51
	SM_UnloadExtension();
ds@1952
    52
ds@1952
    53
	SH_REMOVE_HOOK_STATICFUNC(IServerGameDLL, ServerActivate, server, Hook_ServerActivate, true);
ds@1952
    54
ds@1952
    55
	return true;
ds@1952
    56
}
ds@1952
    57
ds@1952
    58
void Hook_ServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
ds@1952
    59
{
ds@1952
    60
	META_LOG(g_PLAPI, "ServerActivate() called: edictCount = %d, clientMax = %d", edictCount, clientMax);
ds@1952
    61
}
ds@1952
    62
ds@1952
    63
void *StubPlugin::OnMetamodQuery(const char *iface, int *ret)
ds@1952
    64
{
ds@1952
    65
	if (strcmp(iface, SOURCEMOD_NOTICE_EXTENSIONS) == 0)
ds@1952
    66
	{
ds@1952
    67
		BindToSourcemod();
ds@1952
    68
	}
ds@1952
    69
ds@1952
    70
	if (ret != NULL)
ds@1952
    71
	{
ds@1952
    72
		*ret = IFACE_OK;
ds@1952
    73
	}
ds@1952
    74
ds@1952
    75
	return NULL;
ds@1952
    76
}
ds@1952
    77
ds@1952
    78
void StubPlugin::AllPluginsLoaded()
ds@1952
    79
{
ds@1952
    80
	BindToSourcemod();
ds@1952
    81
}
ds@1952
    82
ds@1952
    83
void StubPlugin::BindToSourcemod()
ds@1952
    84
{
ds@1952
    85
	char error[256];
ds@1952
    86
ds@1952
    87
	if (!SM_LoadExtension(error, sizeof(error)))
ds@1952
    88
	{
ds@1952
    89
		char message[512];
ds@1952
    90
		UTIL_Format(message, sizeof(message), "Could not load as a SourceMod extension: %s\n", error);
ds@1952
    91
		engine->LogPrint(message);
ds@1952
    92
	}
ds@1952
    93
}
ds@1952
    94
ds@1952
    95
bool StubPlugin::Pause(char *error, size_t maxlen)
ds@1952
    96
{
ds@1952
    97
	return true;
ds@1952
    98
}
ds@1952
    99
ds@1952
   100
bool StubPlugin::Unpause(char *error, size_t maxlen)
ds@1952
   101
{
ds@1952
   102
	return true;
ds@1952
   103
}
ds@1952
   104
ds@1952
   105
const char *StubPlugin::GetLicense()
ds@1952
   106
{
ds@1952
   107
	return "Public Domain";
ds@1952
   108
}
ds@1952
   109
ds@1952
   110
const char *StubPlugin::GetVersion()
ds@1952
   111
{
ds@1952
   112
	return "1.0.0.0";
ds@1952
   113
}
ds@1952
   114
ds@1952
   115
const char *StubPlugin::GetDate()
ds@1952
   116
{
ds@1952
   117
	return __DATE__;
ds@1952
   118
}
ds@1952
   119
ds@1952
   120
const char *StubPlugin::GetLogTag()
ds@1952
   121
{
ds@1952
   122
	return "STUB";
ds@1952
   123
}
ds@1952
   124
ds@1952
   125
const char *StubPlugin::GetAuthor()
ds@1952
   126
{
ds@1952
   127
	return "AlliedModders LLC";
ds@1952
   128
}
ds@1952
   129
ds@1952
   130
const char *StubPlugin::GetDescription()
ds@1952
   131
{
ds@1952
   132
	return "Sample empty plugin";
ds@1952
   133
}
ds@1952
   134
ds@1952
   135
const char *StubPlugin::GetName()
ds@1952
   136
{
ds@1952
   137
	return "Stub Plugin";
ds@1952
   138
}
ds@1952
   139
ds@1952
   140
const char *StubPlugin::GetURL()
ds@1952
   141
{
ds@1952
   142
	return "http://www.sourcemm.net/";
ds@1952
   143
}
ds@1952
   144