started merging in non-sourcehook changes from 1.5.0

--HG--
branch : sourcemm-1.6.0
extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/branches/sourcemm-1.6.0%40423
This commit is contained in:
David Anderson 2007-09-18 20:35:29 +00:00
parent c325d81b2e
commit 2cf20b1d98
14 changed files with 282 additions and 161 deletions

View File

@ -1,6 +1,6 @@
[PRODUCT]
major = 1
minor = 4
minor = 6
revision = 2
[sourcemm]

View File

@ -302,6 +302,37 @@ CPluginManager::CPlugin *CPluginManager::FindByAPI(ISmmPlugin *api)
return NULL;
}
int CPluginManager::GetPluginCount()
{
return (int)m_Plugins.size();
}
const char *CPluginManager::GetStatusText(CPlugin *pl)
{
switch (pl->m_Status)
{
case Pl_NotFound:
return "NOFILE";
case Pl_Error:
return "ERROR";
case Pl_Refused:
return "FAILED";
case Pl_Paused:
return "PAUSED";
case Pl_Running:
{
if (pl->m_API && pl->m_API->QueryRunning(NULL, 0))
{
return "STOPPED";
} else {
return "RUNNING";
}
}
default:
return "-";
}
}
CPluginManager::CPlugin *CPluginManager::_Load(const char *file, PluginId source, char *error, size_t maxlen)
{
FILE *fp;
@ -607,12 +638,12 @@ void CPluginManager::UnregAllConCmds(CPlugin *pl)
SourceHook::List<ConCommandBase *>::iterator i;
for (i=pl->m_Cvars.begin(); i!=pl->m_Cvars.end(); i++)
g_SMConVarAccessor.Unregister( (*i) );
g_SMConVarAccessor.Unregister(pl->m_Id, (*i) );
pl->m_Cvars.clear();
for (i=pl->m_Cmds.begin(); i!=pl->m_Cmds.end(); i++)
g_SMConVarAccessor.Unregister( (*i) );
g_SMConVarAccessor.Unregister(pl->m_Id, (*i) );
pl->m_Cmds.clear();
}

View File

@ -39,6 +39,7 @@
* New ISmmAPI additions
* 9: New ISmmPluginManager additions
* C 10: Added VSP listen functions to ISmmAPI and IMetamodListener (2007-02-09)
* C 11: New SourceHook version V5 (May, 2007)
*/
#define PLAPI_MIN_VERSION 7
@ -115,6 +116,9 @@ namespace SourceMM
*/
bool Retry(PluginId id, char *error, size_t len);
int GetPluginCount();
const char *GetStatusText(CPlugin *pl);
//get alias info
const char *LookupAlias(const char *alias);
SourceHook::List<SourceMM::CNameAlias *>::iterator _alias_begin();

View File

@ -118,7 +118,7 @@ void CSmmAPI::UnregisterConCmdBase(ISmmPlugin *plugin, ConCommandBase *pCommand)
g_PluginMngr.RemovePluginCvar(plugin, pCommand);
}
g_SMConVarAccessor.Unregister(pCommand);
g_SMConVarAccessor.Unregister(g_PluginMngr.FindByAPI(plugin)->m_Id, pCommand);
}
void CSmmAPI::ConPrint(const char *fmt)
@ -456,6 +456,7 @@ void CSmmAPI::LoadAsVSP()
{
size_t len;
char engine_file[PATH_SIZE];
char engine_path[PATH_SIZE];
char rel_path[PATH_SIZE * 2];
GetFileOfAddress(g_Engine.engine, engine_file, sizeof(engine_file));
@ -471,9 +472,10 @@ void CSmmAPI::LoadAsVSP()
break;
}
}
abspath(engine_path, engine_file);
const char *usepath = g_SmmPath.c_str();
if (UTIL_Relatize(rel_path, sizeof(rel_path), engine_file, g_SmmPath.c_str()))
if (UTIL_Relatize(rel_path, sizeof(rel_path), engine_path, g_SmmPath.c_str()))
{
usepath = rel_path;
}
@ -666,3 +668,7 @@ const char *CSmmAPI::GetUserMessage(int index, int *size)
return msg->name;
}
int CSmmAPI::GetVSPVersion()
{
return g_VspVersion;
}

View File

@ -70,6 +70,7 @@ namespace SourceMM
int GetUserMessageCount();
int FindUserMessage(const char *name, int *size=NULL);
const char *GetUserMessage(int index, int *size=NULL);
int GetVSPVersion();
public:
bool CacheCmds();
bool CmdCacheSuccessful();

View File

@ -303,6 +303,15 @@ public: // Added in 1.4 (1:5)
* @return Message name, or NULL on failure.
*/
virtual const char *GetUserMessage(int index, int *size=NULL) =0;
public: // Added in 1.5.0 (1:6)
/**
* @brief Returns the highest interface version of IServerPluginCallbacks that the engine supports.
* This is useful for games that run on older versions of the Source engine, such as The Ship.
*
* @return Highest interface version of IServerPluginCallbacks.
* Returns 0 if SourceMM's VSP listener isn't currently enabled.
*/
virtual int GetVSPVersion() =0;
};
@ -315,6 +324,7 @@ public: // Added in 1.4 (1:5)
* 1.2.2 Added API for printing to client console (with string formatting).
* 1.3 Added new interface search API.
* 1.4 Added VSP listener and user message API.
* 1.5.0 Added API for getting highest supported version of IServerPluginCallbacks.
*/
#endif //_INCLUDE_ISMM_API_H

View File

@ -20,7 +20,7 @@
#include <sourcehook/sourcehook.h>
#include "ISmmAPI.h"
#define PLAPI_VERSION 10
#define PLAPI_VERSION 12
#define PLAPI_NAME "ISmmPlugin"
class ISmmAPI;
@ -316,6 +316,16 @@ public:
virtual void OnVSPListening(IServerPluginCallbacks *iface)
{
}
/* @brief Called when Metamod:Source is about to remove a concommand or convar.
* This can also be called if ISmmAPI::UnregisterConCmdBase is used by a plugin.
*
* @param id Id of the plugin that created the concommand or convar.
* @param pCommand Pointer to concommand or convar that is being removed.
*/
virtual void OnUnlinkConCommandBase(PluginId id, ConCommandBase *pCommand)
{
}
};
#define PL_EXPOSURE CreateInterface

View File

@ -1,48 +1,64 @@
2007/??/?? 1.6.0:
- Added API for getting highest supported IServerPluginCallbacks interface
version.
- Added OnUnlinkConCommandBase to IMetamodListner to notify when Metamod:Source
is about to remove a concommand or convar.
- The output of the "meta list" command has been reformatted in order to allow
more space for plugins' name, version, and author fields.
2007/06/26 1.4.2:
- Fixed a bug where unloading all plugins could crash if one plugin had child plugins.
- Fixed a bug where unloading all plugins could crash if one plugin had child
plugins.
2007/05/16 1.4.1:
- The client version of the "meta" command should now work with games using the latest
Source beta (srcds0407).
- The client version of the "meta" command should now work with games using the
latest Source beta (srcds0407).
- Fixed amb233 (VSP listener didn't work with Steam dedicated version).
- Fixed amb277 (failed to get user message list in Kreedz Climbing).
- Fixed amb277 (failed to get user message list in Kreedz Climbing).
2007/04/05 1.4.0:
- Added API functions for retrieving User Message info without potentially crashing.
- Added API functions for letting SourceMM plugins use Valve Server Plugin callbacks.
- Added plugin status to client version of "meta list" command. Previously, it did not
differentiate between running and paused plugins.
- Added API functions for retrieving User Message info without potentially
crashing.
- Added API functions for letting SourceMM plugins use Valve Server Plugin
callbacks.
- Added plugin status to client version of "meta list" command. Previously, it
did not differentiate between running and paused plugins.
- An experimental automatic gameinfo.txt fixer is now available.
- Changed version numbering to include the build number (SVN revision).
- Fixed amb93 (improved mod path detection).
- Fixed various rare string inconsistencies.
2006/11/29 1.3d:
- Updated Metamod:Source to recognize the latest Source Engine version (ServerGameDLL006)
- Updated Metamod:Source to recognize the latest Source Engine version
(ServerGameDLL006)
2006/09/06 1.3a:
- Fixed a building issue on Linux which caused unresolved symbol errors when trying to
load Metamod:Source on a game using an older set of engine libraries. This fix should
now allow Metamod:Source to run with The Ship on Linux.
- Fixed a building issue on Linux which caused unresolved symbol errors when
trying to load Metamod:Source on a game using an older set of engine
libraries. This fix should now allow Metamod:Source to run with The Ship on
Linux.
2006/08/16 1.3:
- Added SourceHook support for functions that return references.
- Added some extra information to the "meta game" command: Description and Interface. For
example, CS:S would display "Counter-Strike: Source" and "ServerGameDLL004."
- Added some extra information to the "meta game" command: Description and
Interface. For example, CS:S would display "Counter-Strike: Source" and
"ServerGameDLL004."
- Added some extra functionality to ISmmPluginManager.
- Added compiling support for MSVC 8.0 (Visual Studio 2005) and GCC 4.x
- Added another API helper function for formatting and searching for interfaces.
- Added compiling support for MSVC 8.0 (Visual Studio 2005) and GCC 4.x.
- Added another API helper function for formatting and searching for
interfaces.
- Updated project files and source tree to use the latest HL2SDK.
- Updated the sample plugins to be a bit cleaner and use newer API.
- Fixed bug where Metamod:Source could load the wrong GameDLL and/or load more than one
GameDLL. This issue occured in HL2 CTF, SourceForts, or any other mod that relied on
files from another mod directory.
- Fixed bug where ISmmAPI::MetaFactory() would return the wrong interface when trying to
retrieve ISmmPluginManager.
- Fixed bug where returning false in Load() after adding a Metamod event listener or
hooking a function could cause a crash instead of rejecting the plugin.
- Fixed bug where trying to load Metamod:Source a second time as a SourceMM or Valve
server plugin could cause a crash.
- Fixed bug where Metamod:Source could load the wrong GameDLL and/or load more
than one GameDLL. This issue occured in HL2 CTF, SourceForts, or any other
mod that relied on files from another mod directory.
- Fixed bug where ISmmAPI::MetaFactory() would return the wrong interface when
trying to retrieve ISmmPluginManager.
- Fixed bug where returning false in Load() after adding a Metamod event
listener or hooking a function could cause a crash instead of rejecting the
plugin.
- Fixed bug where trying to load Metamod:Source a second time as a SourceMM or
Valve server plugin could cause a crash.
- Fixed a bug in FormatIface() that caused InterfaceSearch() to infinite loop.
2006/06/14 1.2.3:
@ -54,17 +70,19 @@
- Added "meta alias" command.
- Added SourceHook API for manual callclasses.
- Added support for the latest Source engine (ServerGameDLL005).
- Added API for printing text in a client's console with ClientConPrintf. This does the
same thing as IVEngineServer::ClientPrintf except that it allows string formatting.
- Added client version of "meta" command in order to allow clients to view version
information and a list of loaded plugins.
- Added API for printing text in a client's console with ClientConPrintf. This
does the same thing as IVEngineServer::ClientPrintf except that it allows
string formatting.
- Added client version of "meta" command in order to allow clients to view
version information and a list of loaded plugins.
- Fixed a bug causing old mods on newer engines to fail loading.
- Fixed issues with SourceHook's SH_CALL and reference parameters.
- Fixed a bug where the mm_pluginsfile cvar was being ignored.
- Fixed a memory leak when using ISmmAPI::InterfaceSearch.
2006/02/15 1.2.1:
- Fixed bug where returning newparams in a post hook would cause infinite recursion.
- Fixed bug where returning newparams in a post hook would cause infinite
recursion.
- Fixed bug where "meta load" could load the same plugin multiple times.
- Fixed bug where unloading a plugin could crash internal hook states.
- Fixed bug where unhooking a single hook would clear the hook chain.
@ -76,8 +94,8 @@
- Added API for formatting an OS-independent path.
- Added Listen Server Launcher to the graphical installer.
- Fixed bug where failed plugins could crash the plugin list.
- NOTE: SourceHook changes may require plugins to be recompiled against
the new API.
- NOTE: SourceHook changes may require plugins to be recompiled against the new
API.
2005/12/06 1.1.2:
- Added interface overriding/sharing examples to sample plugins.
@ -90,35 +108,38 @@
- Fixed a bug where AllPluginsLoaded() was not called after DLLInit().
2005/10/21 1.1:
- Rewrote GameDLL loading code to be API version generic.
As such, SourceMM will now easily support new API releases without
an SDK release, such as the case with Day of Defeat:Source
- Rewrote GameDLL loading code to be API version generic. As such, SourceMM
will now easily support new API releases without an SDK release, such as the
case with Day of Defeat:Source.
- Added more flexibility to plugin control by supplying an event system.
- Removed dependency on libstdc++.so by supplying a small template library.
- SourceHook internal API is now interface-based, meaning that future
updates to the API will not break older plugins. This update, however,
breaks older plugins.
- SourceHook internal API is now interface-based, meaning that future updates
to the API will not break older plugins. This update, however, breaks older
plugins.
- SourceHook is now re-entrant.
- Added a basic automated installer (by Basic-Master).
- Fixed a bug where games with changing game names would not work.
- Fixed various bugs, including a cvarlist corruption bug on unloading plugins.
2005/07/07 1.00-RC2:
- Added API for dealing with ConCommandBase registration (cvars/concmds).
This is to fix the fact that Valve API provides no way to unlist a cvar/cmd.
- Added API for dealing with ConCommandBase registration (cvars/concmds). This
is to fix the fact that Valve API provides no way to unlist a cvar/cmd.
- Added two new commands - "meta cmds" and "meta cvars".
- Added API calls for correctly printing to the console such that rcon
will also receive messages that a plugin prints.
This problem was mentioned on hlcoders and Valve offered no reply.
- Added API calls for correctly printing to the console such that rcon will
also receive messages that a plugin prints. This problem was mentioned on
hlcoders and Valve offered no reply.
- Added event hooking and cvar samples to sample_mm.
- Added new cvar, mm_pluginsfile, which defaults to "addons/metamod/metaplugins.ini".
- Fixed a bug where multiple vtable patches on the same hook were not re-patched when removed.
This caused a crash when two hooks were declared on one function, the first was removed, and
the original function was then called.
- Added new cvar, mm_pluginsfile, which defaults to
"addons/metamod/metaplugins.ini".
- Fixed a bug where multiple vtable patches on the same hook were not
re-patched when removed. This caused a crash when two hooks were declared on
one function, the first was removed, and the original function was then
called.
- Fixed "meta clear" not unloading all plugins.
- Fixed Metamod:Source loading plugins with a higher current API version.
- Fixed whitespace being parsed in metaplugins.ini.
- Fixed bug where SourceHook tried to patch already destroyed/unavailable memory.
- Fixed bug where SourceHook tried to patch already destroyed/unavailable
memory.
- Bumped Plugin API version to 6.
2005/05/06 1.00-RC1:

View File

@ -15,6 +15,9 @@
#include "sh_string.h"
#include "sh_list.h"
using namespace SourceMM;
using namespace SourceHook;
/**
* @brief Console Command Implementations
* @file concommands.cpp
@ -50,15 +53,41 @@ bool SMConVarAccessor::Register(ConCommandBase *pCommand)
void SMConVarAccessor::MarkCommandsAsGameDLL()
{
for (SourceHook::List<ConCommandBase*>::iterator iter = m_RegisteredCommands.begin();
for (List<ConCommandBase*>::iterator iter = m_RegisteredCommands.begin();
iter != m_RegisteredCommands.end(); ++iter)
{
(*iter)->AddFlags(FCVAR_GAMEDLL);
}
}
void SMConVarAccessor::Unregister(ConCommandBase *pCommand)
void SMConVarAccessor::Unregister(PluginId id, ConCommandBase *pCommand)
{
/* Notify via IMetamodListener */
PluginIter iter;
CPluginManager::CPlugin *pPlugin;
List<IMetamodListener *>::iterator event;
IMetamodListener *pML;
for (iter=g_PluginMngr._begin(); iter!=g_PluginMngr._end(); iter++)
{
pPlugin = (*iter);
if (pPlugin->m_Status < Pl_Paused)
{
continue;
}
/* Only valid for plugins >= 12 (v1:6, SourceMM 1.5) */
if (pPlugin->m_API->GetApiVersion() < 12)
{
continue;
}
for (event=pPlugin->m_Events.begin();
event!=pPlugin->m_Events.end();
event++)
{
pML = (*event);
pML->OnUnlinkConCommandBase(id, pCommand);
}
}
ICvar *cv = g_Engine.icvar;
ConCommandBase *ptr = cv->GetCommands();
@ -154,7 +183,7 @@ CON_COMMAND(meta, "Metamod:Source Menu")
CONMSG(" Description: %s\n", g_GameDll.pGameDLL->GetGameDescription());
CONMSG(" Mod Path: %s\n", g_ModPath.c_str());
CONMSG(" DLL Path: %s\n", g_BinPath.c_str());
CONMSG(" Interface: ServerGameDLL%03d\n", g_GameDllVersion);
CONMSG(" Interface: ServerGameDLL%03d, ServerGameClients%03d\n", g_GameDllVersion, g_GameClientsVersion);
// Display user messages
if (g_SmmAPI.MsgCacheSuccessful())
@ -191,65 +220,63 @@ CON_COMMAND(meta, "Metamod:Source Menu")
return;
} else if (strcmp(command, "list") == 0) {
SourceMM::CPluginManager::CPlugin *pl;
CPluginManager::CPlugin *pl;
ISmmPlugin *plapi;
const char *plname;
PluginIter i;
const char *status="";
const char *version=NULL;
const char *name=NULL;
const char *author=NULL;
char buffer[256];
int len;
int plnum = g_PluginMngr.GetPluginCount();
CONMSG("-Id- %-20.19s %-10.9s %-20.19s %-8.7s\n", "Name", "Version", "Author", "Status");
for (i=g_PluginMngr._begin(); i!=g_PluginMngr._end(); i++)
if (!plnum)
{
CONMSG("No plugins loaded.\n");
return;
} else {
CONMSG("Listing %d plugin%s:\n", plnum, (plnum > 1) ? "s" : "");
}
for (i = g_PluginMngr._begin(); i != g_PluginMngr._end(); i++)
{
pl = (*i);
if (!pl)
{
break;
if (pl->m_Status == Pl_Paused)
{
status = "PAUSE";
} else if (pl->m_Status == Pl_Running) {
if (pl->m_API && pl->m_API->QueryRunning(NULL, 0))
status = "RUN";
else
status = "STOPPED";
} else if (pl->m_Status == Pl_Refused) {
status = "FAIL";
} else if (pl->m_Status == Pl_Error) {
status = "ERROR";
} else if (pl->m_Status == Pl_NotFound) {
status = "NOFILE";
}
if (pl->m_API)
len = 0;
if (pl->m_Status != Pl_Running)
{
version = pl->m_API->GetVersion();
author = pl->m_API->GetAuthor();
name = pl->m_API->GetName();
len += UTIL_Format(buffer, sizeof(buffer), " [%02d] <%s>", pl->m_Id, g_PluginMngr.GetStatusText(pl));
} else {
version = "-";
author = "-";
name = "-";
len += UTIL_Format(buffer, sizeof(buffer), " [%02d]", pl->m_Id);
}
if (!version)
version = "-";
if (!author)
author = "-";
if (!name)
name = pl->m_File.c_str();
if ((plapi = pl->m_API))
{
plname = IS_STR_FILLED(plapi->GetName()) ? plapi->GetName() : pl->m_File.c_str();
len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " %s", plname);
if (IS_STR_FILLED(plapi->GetVersion()))
{
len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " (%s)", plapi->GetVersion());
}
if (IS_STR_FILLED(plapi->GetAuthor()))
{
UTIL_Format(&buffer[len], sizeof(buffer)-len, " by %s", plapi->GetAuthor());
}
}
CONMSG("[%02d] %-20.19s %-10.9s %-20.19s %-8.7s\n", pl->m_Id, name, version, author, status);
CONMSG("%s\n", buffer);
}
//CONMSG("\n");
return;
} else if (strcmp(command, "cmds") == 0) {
if (args >= 3)
{
int id = atoi(e->Cmd_Argv(2));
SourceMM::CPluginManager::CPlugin *pl = g_PluginMngr.FindById(id);
CPluginManager::CPlugin *pl = g_PluginMngr.FindById(id);
if (!pl)
{
@ -262,7 +289,7 @@ CON_COMMAND(meta, "Metamod:Source Menu")
CONMSG("Plugin %d is not loaded.\n", id);
} else {
CONMSG("Console commands for %s:\n", pl->m_API->GetName());
SourceHook::List<ConCommandBase *>::iterator ci;
List<ConCommandBase *>::iterator ci;
size_t count = 0;
for (ci=pl->m_Cmds.begin(); ci!=pl->m_Cmds.end(); ci++)
@ -280,7 +307,7 @@ CON_COMMAND(meta, "Metamod:Source Menu")
if (args >= 3)
{
int id = atoi(e->Cmd_Argv(2));
SourceMM::CPluginManager::CPlugin *pl = g_PluginMngr.FindById(id);
CPluginManager::CPlugin *pl = g_PluginMngr.FindById(id);
if (!pl)
{
@ -293,7 +320,7 @@ CON_COMMAND(meta, "Metamod:Source Menu")
CONMSG("Plugin %d is not loaded.\n", id);
} else {
CONMSG("Registered cvars for %s:\n", pl->m_API->GetName());
SourceHook::List<ConCommandBase *>::iterator ci;
List<ConCommandBase *>::iterator ci;
size_t count = 0;
for (ci=pl->m_Cvars.begin(); ci!=pl->m_Cvars.end(); ci++)
@ -311,7 +338,7 @@ CON_COMMAND(meta, "Metamod:Source Menu")
if (args >= 3)
{
int id = atoi(e->Cmd_Argv(2));
SourceMM::CPluginManager::CPlugin *pl = g_PluginMngr.FindById(id);
CPluginManager::CPlugin *pl = g_PluginMngr.FindById(id);
if (!pl)
{
CONMSG("Plugin %d not found.\n", id);
@ -420,7 +447,7 @@ CON_COMMAND(meta, "Metamod:Source Menu")
char error[255]={0};
bool already;
SourceMM::CPluginManager::CPlugin *pl;
CPluginManager::CPlugin *pl;
PluginId id = g_PluginMngr.Load(full_path, Pl_Console, already, error, sizeof(error));
pl = g_PluginMngr.FindById(id);
@ -467,8 +494,8 @@ CON_COMMAND(meta, "Metamod:Source Menu")
CONMSG("Alias \"%s\" was not found.\n", alias);
}
} else {
SourceHook::List<SourceMM::CNameAlias *>::iterator iter, end;
SourceMM::CNameAlias *p;
List<CNameAlias *>::iterator iter, end;
CNameAlias *p;
iter = g_PluginMngr._alias_begin();
end = g_PluginMngr._alias_end();
@ -521,8 +548,8 @@ CON_COMMAND(meta, "Metamod:Source Menu")
g_SmmAPI.PathFormat(full_path, sizeof(full_path), "%s/%s%s", g_ModPath.c_str(), file, ext);
}
SourceHook::List<SourceMM::CPluginManager::CPlugin *>::iterator iter, end;
SourceMM::CPluginManager::CPlugin *pl;
List<CPluginManager::CPlugin *>::iterator iter, end;
CPluginManager::CPlugin *pl;
iter = g_PluginMngr._begin();
end = g_PluginMngr._end();
for (; iter!=end; iter++)
@ -703,45 +730,49 @@ void ClientCommand_handler(edict_t *client)
RETURN_META(MRES_SUPERCEDE);
} else if(strcmp(subcmd, "list") == 0) {
SourceMM::CPluginManager::CPlugin *pl;
Pl_Status st;
CPluginManager::CPlugin *pl;
ISmmPlugin *plapi;
const char *plname;
PluginIter i;
const char *version = NULL;
const char *name = NULL;
const char *author = NULL;
const char *status = NULL;
char buffer[256];
int len = 0;
int plnum = 0;
CLIENT_CONMSG(client, "-Id- %-20.19s %-10.9s %-20.19s %6s\n", "Name", "Version", "Author", "Status");
for (i=g_PluginMngr._begin(); i!=g_PluginMngr._end(); i++)
for (i = g_PluginMngr._begin(); i != g_PluginMngr._end(); i++, len=0)
{
pl = (*i);
if (!pl)
break;
st = pl->m_Status;
/* Only show plugins that are running or paused */
if (pl->m_API && (st == Pl_Running || st == Pl_Paused))
if (pl && pl->m_Status == Pl_Running)
{
version = pl->m_API->GetVersion();
author = pl->m_API->GetAuthor();
name = pl->m_API->GetName();
if (st == Pl_Running && pl->m_API->QueryRunning(NULL, 0))
plapi = pl->m_API;
if (!plapi || !plapi->QueryRunning(NULL, 0))
{
status = "RUN";
} else {
status = "PAUSE";
continue;
}
plnum++;
len += UTIL_Format(buffer, sizeof(buffer), " [%02d]", plnum);
plname = IS_STR_FILLED(plapi->GetName()) ? plapi->GetName() : pl->m_File.c_str();
len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " %s", plname);
if (IS_STR_FILLED(plapi->GetVersion()))
{
len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " (%s)", plapi->GetVersion());
}
if (IS_STR_FILLED(plapi->GetAuthor()))
{
UTIL_Format(&buffer[len], sizeof(buffer)-len, " by %s", plapi->GetAuthor());
}
if (!version || !author || !name)
break;
CLIENT_CONMSG(client, "[%02d] %-20.19s %-10.9s %-20.19s %6s\n", pl->m_Id, name, version, author, status);
CLIENT_CONMSG(client, "%s\n", buffer);
}
}
if (!plnum)
{
CLIENT_CONMSG(client, "No active plugins loaded.\n");
}
RETURN_META(MRES_SUPERCEDE);
}
}

View File

@ -29,7 +29,7 @@ public:
virtual bool RegisterConCommandBase(ConCommandBase *pCommand);
bool Register(ConCommandBase *pCommand);
void MarkCommandsAsGameDLL();
void Unregister(ConCommandBase *pCommand);
void Unregister(PluginId id, ConCommandBase *pCommand);
void UnregisterGameDLLCommands();
};

View File

@ -58,8 +58,9 @@ bool bGameInit = false;
SourceHook::List<GameDllInfo *> gamedll_list;
SourceHook::CallClass<IServerGameDLL> *g_GameDllPatch;
int g_GameDllVersion = 0;
const char VSPIFACE_001[] = "ISERVERPLUGINCALLBACKS001";
const char VSPIFACE_002[] = "ISERVERPLUGINCALLBACKS002";
int g_GameClientsVersion = 0;
int g_VspVersion = 0;
const char VSPIFACE[] = "ISERVERPLUGINCALLBACKS";
const char GAMEINFO_PATH[] = "|gameinfo_path|";
void ClearGamedllList();
@ -227,17 +228,18 @@ SMM_API void *CreateInterface(const char *iface, int *ret)
return NULL;
}
/* We check these separately because we can't reply
* unless our interface version really matches.
*/
if ((strcmp(iface, VSPIFACE_002) == 0)
|| strcmp(iface, VSPIFACE_001) == 0)
if (strncmp(iface, VSPIFACE, 22) == 0)
{
if (ret)
g_VspVersion = atoi(&(iface[22]));
if (g_VspVersion <= MAX_VSP_VERSION)
{
*ret = IFACE_OK;
if (ret)
{
*ret = IFACE_OK;
}
return &g_VspListener;
}
return &g_VspListener;
}
if (!gParsedGameInfo)
@ -278,7 +280,6 @@ SMM_API void *CreateInterface(const char *iface, int *ret)
char buffer[255];
char key[128], val[128];
size_t len = 0;
bool search = false;
bool gamebin = false;
char *ptr;
@ -291,9 +292,6 @@ SMM_API void *CreateInterface(const char *iface, int *ret)
{
buffer[0] = '\0';
fgets(buffer, sizeof(buffer), fp);
len = strlen(buffer);
if (buffer[len-1] == '\n')
buffer[--len] = '\0';
UTIL_TrimComments(buffer);
UTIL_TrimLeft(buffer);
UTIL_TrimRight(buffer);
@ -450,6 +448,7 @@ SMM_API void *CreateInterface(const char *iface, int *ret)
{
void *ptr = (g_GameDll.factory)(iface, ret);
g_GameDll.pGameClients = static_cast<IServerGameClients *>(ptr);
g_GameClientsVersion = atoi(&iface[17]);
return ptr;
}

View File

@ -35,12 +35,15 @@
#define SOURCEMM_VERSION SVN_FILE_VERSION_STRING
#define SOURCEMM_DATE __DATE__
#define SM_VERS_API_MAJOR 1 //increase this on a breaking change
#define SM_VERS_API_MINOR 5 //increase this on a non-breaking API change
#define SM_VERS_API_MINOR 6 //increase this on a non-breaking API change
//We need a good CServerGameDLL version to work properly. We support these inclusively.
#define MIN_GAMEDLL_VERSION 3
#define MAX_GAMEDLL_VERSION 8
/* Maximum version of IServerPluginCallbacks that SourceMM supports */
#define MAX_VSP_VERSION 2
/**
* @brief Entry point for HL2 Engine
*/

View File

@ -240,6 +240,19 @@ size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
return len;
}
size_t UTIL_FormatArgs(char *buffer, size_t maxlength, const char *fmt, va_list params)
{
size_t len = vsnprintf(buffer, maxlength, fmt, params);
if (len >= maxlength)
{
len = maxlength - 1;
buffer[len] = '\0';
}
return len;
}
inline bool pathchar_isalpha(char a)
{
return (((a & 1<<7) == 0) && isalpha(a));
@ -393,16 +406,3 @@ bool UTIL_Relatize(char buffer[],
return true;
}
size_t UTIL_FormatArgs(char *buffer, size_t maxlength, const char *fmt, va_list params)
{
size_t len = vsnprintf(buffer, maxlength, fmt, params);
if (len >= maxlength)
{
len = maxlength - 1;
buffer[len] = '\0';
}
return len;
}

View File

@ -18,6 +18,11 @@
* @file util.h
*/
/**
* @brief Returns true is string is not blank, false otherwise.
*/
#define IS_STR_FILLED(var) (var != NULL && var[0] != '\0')
/**
* @brief Returns a pointer to the extension in a file name.
*/