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 --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402037
This commit is contained in:
+176
-145
@@ -1,145 +1,176 @@
|
||||
#include <stdio.h>
|
||||
#include "stub_mm.h"
|
||||
#include "stub_util.h"
|
||||
#include "sm_ext.h"
|
||||
|
||||
MyExtension g_SMExt;
|
||||
|
||||
bool SM_LoadExtension(char *error, size_t maxlength)
|
||||
{
|
||||
if ((smexts = (IExtensionManager *)g_SMAPI->MetaFactory(
|
||||
SOURCEMOD_INTERFACE_EXTENSIONS,
|
||||
NULL,
|
||||
NULL))
|
||||
== NULL)
|
||||
{
|
||||
if (error && maxlength)
|
||||
{
|
||||
UTIL_Format(error, maxlength, SOURCEMOD_INTERFACE_EXTENSIONS " interface not found");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* This could be more dynamic */
|
||||
char path[256];
|
||||
g_SMAPI->PathFormat(path,
|
||||
sizeof(path),
|
||||
"addons/myplugin/bin/myplugin%s",
|
||||
#if defined __linux__
|
||||
"_i486.so"
|
||||
#else
|
||||
".dll"
|
||||
#endif
|
||||
);
|
||||
|
||||
if ((myself = smexts->LoadExternal(&g_SMExt,
|
||||
path,
|
||||
"myplugin_mm.ext",
|
||||
error,
|
||||
maxlength))
|
||||
== NULL)
|
||||
{
|
||||
SM_UnsetInterfaces();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SM_UnloadExtension()
|
||||
{
|
||||
smexts->UnloadExtension(myself);
|
||||
}
|
||||
|
||||
bool MyExtension::OnExtensionLoad(IExtension *me,
|
||||
IShareSys *sys,
|
||||
char *error,
|
||||
size_t maxlength,
|
||||
bool late)
|
||||
{
|
||||
sharesys = sys;
|
||||
myself = me;
|
||||
|
||||
/* Get the default interfaces from our configured SDK header */
|
||||
if (!SM_AcquireInterfaces(error, maxlength))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MyExtension::OnExtensionUnload()
|
||||
{
|
||||
/* Clean up any resources here, and more importantly, make sure
|
||||
* any listeners/hooks into SourceMod are totally removed, as well
|
||||
* as data structures like handle types and forwards.
|
||||
*/
|
||||
|
||||
//...
|
||||
|
||||
/* Make sure our pointers get NULL'd just in case */
|
||||
SM_UnsetInterfaces();
|
||||
}
|
||||
|
||||
void MyExtension::OnExtensionsAllLoaded()
|
||||
{
|
||||
/* Called once all extensions are marked as loaded.
|
||||
* This always called, and always called only once.
|
||||
*/
|
||||
}
|
||||
|
||||
void MyExtension::OnExtensionPauseChange(bool pause)
|
||||
{
|
||||
}
|
||||
|
||||
bool MyExtension::QueryRunning(char *error, size_t maxlength)
|
||||
{
|
||||
/* if something is required that can't be determined during the initial
|
||||
* load process, print a message here will show a helpful message to
|
||||
* users when they view the extension's info.
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MyExtension::IsMetamodExtension()
|
||||
{
|
||||
/* Must return false! */
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionName()
|
||||
{
|
||||
return mmsplugin->GetName();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionURL()
|
||||
{
|
||||
return mmsplugin->GetURL();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionTag()
|
||||
{
|
||||
return mmsplugin->GetLogTag();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionAuthor()
|
||||
{
|
||||
return mmsplugin->GetAuthor();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionVerString()
|
||||
{
|
||||
return mmsplugin->GetVersion();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionDescription()
|
||||
{
|
||||
return mmsplugin->GetDescription();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionDateString()
|
||||
{
|
||||
return mmsplugin->GetDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Extension Code for Metamod:Source
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "stub_mm.h"
|
||||
#include "stub_util.h"
|
||||
#include "sm_ext.h"
|
||||
|
||||
MyExtension g_SMExt;
|
||||
|
||||
bool SM_LoadExtension(char *error, size_t maxlength)
|
||||
{
|
||||
if ((smexts = (IExtensionManager *)g_SMAPI->MetaFactory(
|
||||
SOURCEMOD_INTERFACE_EXTENSIONS,
|
||||
NULL,
|
||||
NULL))
|
||||
== NULL)
|
||||
{
|
||||
if (error && maxlength)
|
||||
{
|
||||
UTIL_Format(error, maxlength, SOURCEMOD_INTERFACE_EXTENSIONS " interface not found");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* This could be more dynamic */
|
||||
char path[256];
|
||||
g_SMAPI->PathFormat(path,
|
||||
sizeof(path),
|
||||
"addons/myplugin/bin/myplugin%s",
|
||||
#if defined __linux__
|
||||
"_i486.so"
|
||||
#else
|
||||
".dll"
|
||||
#endif
|
||||
);
|
||||
|
||||
if ((myself = smexts->LoadExternal(&g_SMExt,
|
||||
path,
|
||||
"myplugin_mm.ext",
|
||||
error,
|
||||
maxlength))
|
||||
== NULL)
|
||||
{
|
||||
SM_UnsetInterfaces();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SM_UnloadExtension()
|
||||
{
|
||||
smexts->UnloadExtension(myself);
|
||||
}
|
||||
|
||||
bool MyExtension::OnExtensionLoad(IExtension *me,
|
||||
IShareSys *sys,
|
||||
char *error,
|
||||
size_t maxlength,
|
||||
bool late)
|
||||
{
|
||||
sharesys = sys;
|
||||
myself = me;
|
||||
|
||||
/* Get the default interfaces from our configured SDK header */
|
||||
if (!SM_AcquireInterfaces(error, maxlength))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MyExtension::OnExtensionUnload()
|
||||
{
|
||||
/* Clean up any resources here, and more importantly, make sure
|
||||
* any listeners/hooks into SourceMod are totally removed, as well
|
||||
* as data structures like handle types and forwards.
|
||||
*/
|
||||
|
||||
//...
|
||||
|
||||
/* Make sure our pointers get NULL'd just in case */
|
||||
SM_UnsetInterfaces();
|
||||
}
|
||||
|
||||
void MyExtension::OnExtensionsAllLoaded()
|
||||
{
|
||||
/* Called once all extensions are marked as loaded.
|
||||
* This always called, and always called only once.
|
||||
*/
|
||||
}
|
||||
|
||||
void MyExtension::OnExtensionPauseChange(bool pause)
|
||||
{
|
||||
}
|
||||
|
||||
bool MyExtension::QueryRunning(char *error, size_t maxlength)
|
||||
{
|
||||
/* if something is required that can't be determined during the initial
|
||||
* load process, print a message here will show a helpful message to
|
||||
* users when they view the extension's info.
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MyExtension::IsMetamodExtension()
|
||||
{
|
||||
/* Must return false! */
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionName()
|
||||
{
|
||||
return mmsplugin->GetName();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionURL()
|
||||
{
|
||||
return mmsplugin->GetURL();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionTag()
|
||||
{
|
||||
return mmsplugin->GetLogTag();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionAuthor()
|
||||
{
|
||||
return mmsplugin->GetAuthor();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionVerString()
|
||||
{
|
||||
return mmsplugin->GetVersion();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionDescription()
|
||||
{
|
||||
return mmsplugin->GetDescription();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionDateString()
|
||||
{
|
||||
return mmsplugin->GetDate();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,38 +1,69 @@
|
||||
#ifndef _INCLUDE_SAMPLE_MMS_SOURCEMOD_EXTENSION_
|
||||
#define _INCLUDE_SAMPLE_MMS_SOURCEMOD_EXTENSION_
|
||||
|
||||
#include "sm_sdk_config.h"
|
||||
|
||||
using namespace SourceMod;
|
||||
|
||||
class MyExtension : public IExtensionInterface
|
||||
{
|
||||
public:
|
||||
virtual bool OnExtensionLoad(IExtension *me,
|
||||
IShareSys *sys,
|
||||
char *error,
|
||||
size_t maxlength,
|
||||
bool late);
|
||||
virtual void OnExtensionUnload();
|
||||
virtual void OnExtensionsAllLoaded();
|
||||
virtual void OnExtensionPauseChange(bool pause);
|
||||
virtual bool QueryRunning(char *error, size_t maxlength);
|
||||
virtual bool IsMetamodExtension();
|
||||
virtual const char *GetExtensionName();
|
||||
virtual const char *GetExtensionURL();
|
||||
virtual const char *GetExtensionTag();
|
||||
virtual const char *GetExtensionAuthor();
|
||||
virtual const char *GetExtensionVerString();
|
||||
virtual const char *GetExtensionDescription();
|
||||
virtual const char *GetExtensionDateString();
|
||||
};
|
||||
|
||||
bool SM_LoadExtension(char *error, size_t maxlength);
|
||||
void SM_UnloadExtension();
|
||||
|
||||
extern IShareSys *sharesys;
|
||||
extern IExtension *myself;
|
||||
extern MyExtension g_SMExt;
|
||||
|
||||
#endif //_INCLUDE_SAMPLE_MMS_SOURCEMOD_EXTENSION_
|
||||
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Extension Code for Metamod:Source
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SAMPLE_MMS_SOURCEMOD_EXTENSION_
|
||||
#define _INCLUDE_SAMPLE_MMS_SOURCEMOD_EXTENSION_
|
||||
|
||||
#include "sm_sdk_config.h"
|
||||
|
||||
using namespace SourceMod;
|
||||
|
||||
class MyExtension : public IExtensionInterface
|
||||
{
|
||||
public:
|
||||
virtual bool OnExtensionLoad(IExtension *me,
|
||||
IShareSys *sys,
|
||||
char *error,
|
||||
size_t maxlength,
|
||||
bool late);
|
||||
virtual void OnExtensionUnload();
|
||||
virtual void OnExtensionsAllLoaded();
|
||||
virtual void OnExtensionPauseChange(bool pause);
|
||||
virtual bool QueryRunning(char *error, size_t maxlength);
|
||||
virtual bool IsMetamodExtension();
|
||||
virtual const char *GetExtensionName();
|
||||
virtual const char *GetExtensionURL();
|
||||
virtual const char *GetExtensionTag();
|
||||
virtual const char *GetExtensionAuthor();
|
||||
virtual const char *GetExtensionVerString();
|
||||
virtual const char *GetExtensionDescription();
|
||||
virtual const char *GetExtensionDateString();
|
||||
};
|
||||
|
||||
bool SM_LoadExtension(char *error, size_t maxlength);
|
||||
void SM_UnloadExtension();
|
||||
|
||||
extern IShareSys *sharesys;
|
||||
extern IExtension *myself;
|
||||
extern MyExtension g_SMExt;
|
||||
|
||||
#endif //_INCLUDE_SAMPLE_MMS_SOURCEMOD_EXTENSION_
|
||||
|
||||
|
||||
@@ -1,151 +1,182 @@
|
||||
#include "sm_sdk_config.h"
|
||||
|
||||
using namespace SourceMod;
|
||||
|
||||
bool SM_AcquireInterfaces(char *error, size_t maxlength)
|
||||
{
|
||||
SM_FIND_IFACE_OR_FAIL(SOURCEMOD, sm_main, error, maxlength);
|
||||
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
SM_FIND_IFACE_OR_FAIL(FORWARDMANAGER, sm_forwards, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_HANDLESYS
|
||||
SM_FIND_IFACE_OR_FAIL(HANDLESYSTEM, sm_handlesys, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
SM_FIND_IFACE_OR_FAIL(PLAYERMANAGER, sm_players, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
SM_FIND_IFACE_OR_FAIL(DBI, sm_dbi, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
SM_FIND_IFACE_OR_FAIL(GAMECONFIG, sm_gameconfs, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
SM_FIND_IFACE_OR_FAIL(MEMORYUTILS, sm_memutils, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
SM_FIND_IFACE_OR_FAIL(GAMEHELPERS, sm_gamehelpers, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
SM_FIND_IFACE_OR_FAIL(TIMERSYS, sm_timersys, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
SM_FIND_IFACE_OR_FAIL(THREADER, sm_threader, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
SM_FIND_IFACE_OR_FAIL(LIBRARYSYS, sm_libsys, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
SM_FIND_IFACE_OR_FAIL(PLUGINSYSTEM, sm_plsys, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
SM_FIND_IFACE_OR_FAIL(MENUMANAGER, sm_menus, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
SM_FIND_IFACE_OR_FAIL(ADMINSYS, sm_adminsys, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||
SM_FIND_IFACE_OR_FAIL(TEXTPARSERS, sm_text, error, maxlength);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SM_UnsetInterfaces()
|
||||
{
|
||||
myself = NULL;
|
||||
smexts = NULL;
|
||||
sharesys = NULL;
|
||||
sm_main = NULL;
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
sm_forwards = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_HANDLESYS
|
||||
sm_handlesys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
sm_players = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
sm_dbi = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
sm_gameconfs = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
sm_memutils = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
sm_gamehelpers = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
sm_timersys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
sm_threader = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
sm_libsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
sm_plsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
sm_menus = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
sm_adminsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||
sm_text = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
IExtension *myself = NULL;
|
||||
IExtensionManager *smexts = NULL;
|
||||
IShareSys *sharesys = NULL;
|
||||
SourceMod::ISourceMod *sm_main = NULL;
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
SourceMod::IForwardManager *sm_forwards = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_HANDLESYS
|
||||
SourceMod::IHandleSys *sm_handlesys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
SourceMod::IPlayerManager *sm_players = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
SourceMod::IDBManager *sm_dbi = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
SourceMod::IGameConfigManager *sm_gameconfs = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
SourceMod::IMemoryUtils *sm_memutils = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
SourceMod::IGameHelpers *sm_gamehelpers = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
SourceMod::ITimerSystem *sm_timersys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
SourceMod::IThreader *sm_threader = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
SourceMod::ILibrarySys *sm_libsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
SourceMod::IPluginManager *sm_plsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
SourceMod::IMenuManager *sm_menus = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
SourceMod::IAdminSystem *sm_adminsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||
SourceMod::ITextParsers *sm_text = NULL;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Extension Code for Metamod:Source
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include "sm_sdk_config.h"
|
||||
|
||||
using namespace SourceMod;
|
||||
|
||||
bool SM_AcquireInterfaces(char *error, size_t maxlength)
|
||||
{
|
||||
SM_FIND_IFACE_OR_FAIL(SOURCEMOD, sm_main, error, maxlength);
|
||||
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
SM_FIND_IFACE_OR_FAIL(FORWARDMANAGER, sm_forwards, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_HANDLESYS
|
||||
SM_FIND_IFACE_OR_FAIL(HANDLESYSTEM, sm_handlesys, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
SM_FIND_IFACE_OR_FAIL(PLAYERMANAGER, sm_players, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
SM_FIND_IFACE_OR_FAIL(DBI, sm_dbi, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
SM_FIND_IFACE_OR_FAIL(GAMECONFIG, sm_gameconfs, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
SM_FIND_IFACE_OR_FAIL(MEMORYUTILS, sm_memutils, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
SM_FIND_IFACE_OR_FAIL(GAMEHELPERS, sm_gamehelpers, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
SM_FIND_IFACE_OR_FAIL(TIMERSYS, sm_timersys, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
SM_FIND_IFACE_OR_FAIL(THREADER, sm_threader, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
SM_FIND_IFACE_OR_FAIL(LIBRARYSYS, sm_libsys, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
SM_FIND_IFACE_OR_FAIL(PLUGINSYSTEM, sm_plsys, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
SM_FIND_IFACE_OR_FAIL(MENUMANAGER, sm_menus, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
SM_FIND_IFACE_OR_FAIL(ADMINSYS, sm_adminsys, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||
SM_FIND_IFACE_OR_FAIL(TEXTPARSERS, sm_text, error, maxlength);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SM_UnsetInterfaces()
|
||||
{
|
||||
myself = NULL;
|
||||
smexts = NULL;
|
||||
sharesys = NULL;
|
||||
sm_main = NULL;
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
sm_forwards = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_HANDLESYS
|
||||
sm_handlesys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
sm_players = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
sm_dbi = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
sm_gameconfs = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
sm_memutils = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
sm_gamehelpers = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
sm_timersys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
sm_threader = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
sm_libsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
sm_plsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
sm_menus = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
sm_adminsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||
sm_text = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
IExtension *myself = NULL;
|
||||
IExtensionManager *smexts = NULL;
|
||||
IShareSys *sharesys = NULL;
|
||||
SourceMod::ISourceMod *sm_main = NULL;
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
SourceMod::IForwardManager *sm_forwards = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_HANDLESYS
|
||||
SourceMod::IHandleSys *sm_handlesys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
SourceMod::IPlayerManager *sm_players = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
SourceMod::IDBManager *sm_dbi = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
SourceMod::IGameConfigManager *sm_gameconfs = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
SourceMod::IMemoryUtils *sm_memutils = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
SourceMod::IGameHelpers *sm_gamehelpers = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
SourceMod::ITimerSystem *sm_timersys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
SourceMod::IThreader *sm_threader = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
SourceMod::ILibrarySys *sm_libsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
SourceMod::IPluginManager *sm_plsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
SourceMod::IMenuManager *sm_menus = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
SourceMod::IAdminSystem *sm_adminsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||
SourceMod::ITextParsers *sm_text = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,128 +1,159 @@
|
||||
#ifndef _INCLUDE_SOURCEMOD_CONFIG_H_
|
||||
#define _INCLUDE_SOURCEMOD_CONFIG_H_
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/**
|
||||
* @brief Acquires the interfaces enabled at the bottom of this header.
|
||||
*
|
||||
* @param error Buffer to store error message.
|
||||
* @param maxlength Maximum size of the error buffer.
|
||||
* @return True on success, false on failure.
|
||||
* On failure, a null-terminated string will be stored
|
||||
* in the error buffer, if the buffer is non-NULL and
|
||||
* greater than 0 bytes in size.
|
||||
*/
|
||||
bool SM_AcquireInterfaces(char *error, size_t maxlength);
|
||||
|
||||
/**
|
||||
* @brief Sets each acquired interface to NULL.
|
||||
*/
|
||||
void SM_UnsetInterfaces();
|
||||
|
||||
/**
|
||||
* Enable interfaces you want to use here by uncommenting lines.
|
||||
* These interfaces are all part of SourceMod's core.
|
||||
*/
|
||||
//#define SMEXT_ENABLE_FORWARDSYS
|
||||
//#define SMEXT_ENABLE_HANDLESYS
|
||||
//#define SMEXT_ENABLE_PLAYERHELPERS
|
||||
//#define SMEXT_ENABLE_DBMANAGER
|
||||
//#define SMEXT_ENABLE_GAMECONF
|
||||
//#define SMEXT_ENABLE_MEMUTILS
|
||||
//#define SMEXT_ENABLE_GAMEHELPERS
|
||||
//#define SMEXT_ENABLE_TIMERSYS
|
||||
//#define SMEXT_ENABLE_THREADER
|
||||
//#define SMEXT_ENABLE_LIBSYS
|
||||
//#define SMEXT_ENABLE_MENUS
|
||||
//#define SMEXT_ENABLE_ADTFACTORY
|
||||
//#define SMEXT_ENABLE_PLUGINSYS
|
||||
//#define SMEXT_ENABLE_ADMINSYS
|
||||
//#define SMEXT_ENABLE_TEXTPARSERS
|
||||
|
||||
|
||||
/**
|
||||
* There is no need to edit below.
|
||||
*/
|
||||
|
||||
#include <IShareSys.h>
|
||||
#include <IExtensionSys.h>
|
||||
extern SourceMod::IExtension *myself;
|
||||
extern SourceMod::IExtensionManager *smexts;
|
||||
extern SourceMod::IShareSys *sharesys;
|
||||
|
||||
#include <ISourceMod.h>
|
||||
extern SourceMod::ISourceMod *sm_main;
|
||||
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
#include <IForwardSys.h>
|
||||
extern SourceMod::IForwardManager *sm_forwards;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_HANDLESYS
|
||||
#include <IHandleSys.h>
|
||||
extern SourceMod::IHandleSys *sm_handlesys;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
#include <IPlayerHelpers.h>
|
||||
extern SourceMod::IPlayerManager *sm_players;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
#include <IDBDriver.h>
|
||||
extern SourceMod::IDBManager *sm_dbi;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
#include <IGameConfigs.h>
|
||||
extern SourceMod::IGameConfigManager *sm_gameconfs;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
#include <IMemoryUtils.h>
|
||||
extern SourceMod::IMemoryUtils *sm_memutils;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
#include <IGameHelpers.h>
|
||||
extern SourceMod::IGameHelpers *sm_gamehelpers;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
#include <ITimerSystem.h>
|
||||
extern SourceMod::ITimerSystem *sm_timersys;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
#include <IThreader.h>
|
||||
extern SourceMod::IThreader *sm_threader;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
#include <ILibrarySys.h>
|
||||
extern SourceMod::ILibrarySys *sm_libsys;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
#include <IPluginSys.h>
|
||||
extern SourceMod::IPluginManager *sm_plsys;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
#include <IMenuManager.h>
|
||||
extern SourceMod::IMenuManager *sm_menus;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
#include <IAdminSystem.h>
|
||||
extern SourceMod::IAdminSystem *sm_adminsys;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||
#include <ITextParsers.h>
|
||||
extern SourceMod::ITextParsers *sm_text;
|
||||
#endif
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_CONFIG_H_
|
||||
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Extension Code for Metamod:Source
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_CONFIG_H_
|
||||
#define _INCLUDE_SOURCEMOD_CONFIG_H_
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/**
|
||||
* @brief Acquires the interfaces enabled at the bottom of this header.
|
||||
*
|
||||
* @param error Buffer to store error message.
|
||||
* @param maxlength Maximum size of the error buffer.
|
||||
* @return True on success, false on failure.
|
||||
* On failure, a null-terminated string will be stored
|
||||
* in the error buffer, if the buffer is non-NULL and
|
||||
* greater than 0 bytes in size.
|
||||
*/
|
||||
bool SM_AcquireInterfaces(char *error, size_t maxlength);
|
||||
|
||||
/**
|
||||
* @brief Sets each acquired interface to NULL.
|
||||
*/
|
||||
void SM_UnsetInterfaces();
|
||||
|
||||
/**
|
||||
* Enable interfaces you want to use here by uncommenting lines.
|
||||
* These interfaces are all part of SourceMod's core.
|
||||
*/
|
||||
//#define SMEXT_ENABLE_FORWARDSYS
|
||||
//#define SMEXT_ENABLE_HANDLESYS
|
||||
//#define SMEXT_ENABLE_PLAYERHELPERS
|
||||
//#define SMEXT_ENABLE_DBMANAGER
|
||||
//#define SMEXT_ENABLE_GAMECONF
|
||||
//#define SMEXT_ENABLE_MEMUTILS
|
||||
//#define SMEXT_ENABLE_GAMEHELPERS
|
||||
//#define SMEXT_ENABLE_TIMERSYS
|
||||
//#define SMEXT_ENABLE_THREADER
|
||||
//#define SMEXT_ENABLE_LIBSYS
|
||||
//#define SMEXT_ENABLE_MENUS
|
||||
//#define SMEXT_ENABLE_ADTFACTORY
|
||||
//#define SMEXT_ENABLE_PLUGINSYS
|
||||
//#define SMEXT_ENABLE_ADMINSYS
|
||||
//#define SMEXT_ENABLE_TEXTPARSERS
|
||||
|
||||
|
||||
/**
|
||||
* There is no need to edit below.
|
||||
*/
|
||||
|
||||
#include <IShareSys.h>
|
||||
#include <IExtensionSys.h>
|
||||
extern SourceMod::IExtension *myself;
|
||||
extern SourceMod::IExtensionManager *smexts;
|
||||
extern SourceMod::IShareSys *sharesys;
|
||||
|
||||
#include <ISourceMod.h>
|
||||
extern SourceMod::ISourceMod *sm_main;
|
||||
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
#include <IForwardSys.h>
|
||||
extern SourceMod::IForwardManager *sm_forwards;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_HANDLESYS
|
||||
#include <IHandleSys.h>
|
||||
extern SourceMod::IHandleSys *sm_handlesys;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
#include <IPlayerHelpers.h>
|
||||
extern SourceMod::IPlayerManager *sm_players;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
#include <IDBDriver.h>
|
||||
extern SourceMod::IDBManager *sm_dbi;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
#include <IGameConfigs.h>
|
||||
extern SourceMod::IGameConfigManager *sm_gameconfs;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
#include <IMemoryUtils.h>
|
||||
extern SourceMod::IMemoryUtils *sm_memutils;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
#include <IGameHelpers.h>
|
||||
extern SourceMod::IGameHelpers *sm_gamehelpers;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
#include <ITimerSystem.h>
|
||||
extern SourceMod::ITimerSystem *sm_timersys;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
#include <IThreader.h>
|
||||
extern SourceMod::IThreader *sm_threader;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
#include <ILibrarySys.h>
|
||||
extern SourceMod::ILibrarySys *sm_libsys;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
#include <IPluginSys.h>
|
||||
extern SourceMod::IPluginManager *sm_plsys;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
#include <IMenuManager.h>
|
||||
extern SourceMod::IMenuManager *sm_menus;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
#include <IAdminSystem.h>
|
||||
extern SourceMod::IAdminSystem *sm_adminsys;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||
#include <ITextParsers.h>
|
||||
extern SourceMod::ITextParsers *sm_text;
|
||||
#endif
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_CONFIG_H_
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*
|
||||
* This stub plugin is public domain.
|
||||
*
|
||||
* Version: $Id: stub_mm.cpp 534 2007-10-30 18:22:12Z dvander $
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*
|
||||
* This stub plugin is public domain.
|
||||
*
|
||||
* Version: $Id: stub_mm.h 463 2007-10-06 17:01:51Z dvander $
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_METAMOD_SOURCE_STUB_PLUGIN_H_
|
||||
|
||||
@@ -1,22 +1,38 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "stub_util.h"
|
||||
|
||||
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (len >= maxlength)
|
||||
{
|
||||
len = maxlength - 1;
|
||||
buffer[len] = '\0';
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* ======================================================
|
||||
* Metamod:Source Stub Plugin
|
||||
* Written by AlliedModders LLC.
|
||||
* ======================================================
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from
|
||||
* the use of this software.
|
||||
*
|
||||
* This stub plugin is public domain.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "stub_util.h"
|
||||
|
||||
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (len >= maxlength)
|
||||
{
|
||||
len = maxlength - 1;
|
||||
buffer[len] = '\0';
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,15 +1,31 @@
|
||||
#ifndef _INCLUDE_STUB_UTIL_FUNCTIONS_H_
|
||||
#define _INCLUDE_STUB_UTIL_FUNCTIONS_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
* This is a platform-safe function which fixes weird idiosyncracies
|
||||
* in the null-termination and return value of snprintf(). It guarantees
|
||||
* the terminator on overflow cases, and never returns -1 or a value
|
||||
* not equal to the number of non-terminating bytes written.
|
||||
*/
|
||||
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||
|
||||
#endif //_INCLUDE_STUB_UTIL_FUNCTIONS_H_
|
||||
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* ======================================================
|
||||
* Metamod:Source Stub Plugin
|
||||
* Written by AlliedModders LLC.
|
||||
* ======================================================
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from
|
||||
* the use of this software.
|
||||
*
|
||||
* This stub plugin is public domain.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_STUB_UTIL_FUNCTIONS_H_
|
||||
#define _INCLUDE_STUB_UTIL_FUNCTIONS_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
* This is a platform-safe function which fixes weird idiosyncracies
|
||||
* in the null-termination and return value of snprintf(). It guarantees
|
||||
* the terminator on overflow cases, and never returns -1 or a value
|
||||
* not equal to the number of non-terminating bytes written.
|
||||
*/
|
||||
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||
|
||||
#endif //_INCLUDE_STUB_UTIL_FUNCTIONS_H_
|
||||
|
||||
|
||||
Reference in New Issue
Block a user