Fixed tags for mmsource-central
mmsource-1.00-RC1 - Not tagged originally, but eventually done by Scott Ehlert <
[email protected]> on Wed Jul 19 08:41:34 2006 UTC
mmsource-1.00-RC2 - Not tagged originally, but eventually done by Scott Ehlert <
[email protected]> on Wed Jul 19 08:35:20 2006 UTC
mmsource-1.00 - Not tagged originally, but eventually done by Scott Ehlert <
[email protected]> on Wed Jul 19 08:30:40 2006 UTC
mmsource-1.1 - Not tagged originally, but eventually done by Scott Ehlert <
[email protected]> on Wed Jul 19 08:25:09 2006 UTC
mmsource-1.1.1 - Not tagged originally, but eventually done by Scott Ehlert <
[email protected]> on Wed Jul 19 08:22:23 2006 UTC
mmsource-1.1.2 - Not tagged originally, but eventually done by Scott Ehlert <
[email protected]> on Wed Jul 19 08:14:00 2006 UTC
mmsource-1.2 - Not tagged originally, but eventually done by Scott Ehlert <
[email protected]> on Wed Jul 19 08:10:47 2006 UTC
mmsource-1.2.1 - Not tagged originally, but eventually done by Scott Ehlert <
[email protected]> on Wed Jul 19 08:01:35 2006 UTC
mmsource-1.2.2 - Not tagged originally, but eventually done by Scott Ehlert <
[email protected]> on Wed Jul 19 07:57:26 2006 UTC
mmsource-1.2.3 - Not tagged originally, but eventually done by David Anderson <
[email protected]> on Wed Jul 12 17:33:59 2006 UTC
mmsource-1.3 - Originally tagged by Scott Ehlert <
[email protected]> on Thu Aug 17 03:19:55 2006 UTC
mmsource-1.3a - Originally tagged by Scott Ehlert <
[email protected]> on Wed Sep 6 07:17:37 2006 UTC
mmsource-1.3d - Originally tagged by Scott Ehlert <
[email protected]> on Fri Feb 2 05:30:56 2007 UTC
mmsource-1.4 - Originally tagged by Scott Ehlert <
[email protected]> on Sat Apr 7 05:00:28 2007 UTC
mmsource-1.6.0 - Originally tagged by David Anderson <
[email protected]> on Mon Feb 18 23:31:29 2008 UTC
mmsource-1.6.1 - Originally tagged by David Anderson <
[email protected]> on Mon Feb 25 17:15:44 2008 UTC
mmsource-1.6.2 - Originally tagged by David Anderson <
[email protected]> on Sat Jul 26 05:04:35 2008 UTC
3 * ======================================================
5 * Copyright (C) 2004-2008 AlliedModders LLC and authors.
7 * ======================================================
9 * This software is provided 'as-is', without any express or implied warranty.
10 * In no event will the authors be held liable for any damages arising from
11 * the use of this software.
13 * Permission is granted to anyone to use this software for any purpose,
14 * including commercial applications, and to alter it and redistribute it
15 * freely, subject to the following restrictions:
17 * 1. The origin of this software must not be misrepresented; you must not
18 * claim that you wrote the original software. If you use this software in a
19 * product, an acknowledgment in the product documentation would be
20 * appreciated but is not required.
21 * 2. Altered source versions must be plainly marked as such, and must not be
22 * misrepresented as being the original software.
23 * 3. This notice may not be removed or altered from any source distribution.
28 #include "metamod_oslink.h"
31 #include "metamod_util.h"
32 #include "metamod_console.h"
33 #include "metamod_plugins.h"
35 using namespace SourceMM;
36 using namespace SourceHook;
39 * @brief Console Command Implementations
40 * @file concommands.cpp
43 #define CONMSG g_Metamod.ConPrintf
44 #define CLIENT_CONMSG g_Metamod.ClientConPrintf
46 bool Command_Meta(IMetamodSourceCommandInfo *info)
48 unsigned int args = info->GetArgCount();
50 if (provider->IsAlternatelyLoaded() && !g_Metamod.IsAlternateLoadComplete())
52 CONMSG("You must change the map to activate Metamod:Source.\n");
58 const char *command = info->GetArg(1);
59 if (strcmp(command, "credits") == 0)
61 CONMSG("Metamod:Source was developed by:\n");
62 CONMSG(" SourceHook: Pavol \"PM OnoTo\" Marko\n");
63 CONMSG(" GameDLL/Plugins: David \"BAILOPAN\" Anderson\n");
64 CONMSG(" GameDLL: Scott \"Damaged Soul\" Ehlert\n");
65 CONMSG("For more information, see the official website\n");
66 CONMSG("http://www.metamodsource.net/\n");
70 else if (strcmp(command, "version") == 0)
72 CONMSG("Metamod:Source version %s\n", SOURCEMM_VERSION);
74 if (g_Metamod.IsLoadedAsGameDLL())
76 CONMSG("Loaded As: GameDLL (gameinfo.txt)\n");
80 CONMSG("Loaded As: Valve Server Plugin\n");
83 CONMSG("Compiled on: %s\n", SOURCEMM_DATE);
84 CONMSG("Plugin interface version: %d:%d\n", METAMOD_PLAPI_VERSION, PLAPI_MIN_VERSION);
85 CONMSG("SourceHook version: %d:%d\n", g_SHPtr->GetIfaceVersion(), g_SHPtr->GetImplVersion());
86 CONMSG("http://www.metamodsource.net/\n");
90 else if (strcmp(command, "game") == 0)
92 CONMSG("GameDLL Information\n");
93 CONMSG(" Description: %s\n", provider->GetGameDescription());
94 CONMSG(" Mod Path: %s\n", g_Metamod.GetBaseDir());
95 CONMSG(" DLL Path: %s\n", g_Metamod.GetGameBinaryPath());
96 CONMSG(" Interface: ServerGameDLL%03d\n", g_Metamod.GetGameDLLVersion());
98 int engine = g_Metamod.GetSourceEngineBuild();
99 if (engine == SOURCE_ENGINE_ORIGINAL)
101 CONMSG(" Engine: Original (pre-Episode 1)\n");
103 else if (engine == SOURCE_ENGINE_EPISODEONE)
105 CONMSG(" Engine: Episode 1 (2004)\n");
107 else if (engine == SOURCE_ENGINE_ORANGEBOX)
109 CONMSG(" Engine: Episode 2 (Orange Box, 2007)\n");
112 // Display user messages
113 int messages = g_Metamod.GetUserMessageCount();
121 CONMSG(" User Messages: %-32.31s %-5s %-5s\n", "Name", "Index", "Size");
123 for (int i = 0; i < messages; i++)
125 msgname = g_Metamod.GetUserMessage(i, &msgsize);
127 CONMSG(" %-32.31s %-5d %-5d\n", msgname, i, msgsize);
130 CONMSG(" %d user message%s in total\n", messages, (messages > 1) ? "s" : "");
134 CONMSG(" User Messages: None\n");
139 CONMSG(" User Messages: Failed to get list of user messages\n");
144 else if (strcmp(command, "refresh") == 0)
147 g_Metamod.PathFormat(full_path,
150 g_Metamod.GetBaseDir(),
151 g_Metamod.GetPluginsFile());
153 LoadPluginsFromFile(full_path);
157 else if (strcmp(command, "list") == 0)
159 CPluginManager::CPlugin *pl;
165 int plnum = g_PluginMngr.GetPluginCount();
169 CONMSG("No plugins loaded.\n");
172 CONMSG("Listing %d plugin%s:\n", plnum, (plnum > 1) ? "s" : "");
175 for (i = g_PluginMngr._begin(); i != g_PluginMngr._end(); i++)
185 if (pl->m_Status != Pl_Running)
187 len += UTIL_Format(buffer, sizeof(buffer), " [%02d] <%s>", pl->m_Id, g_PluginMngr.GetStatusText(pl));
189 len += UTIL_Format(buffer, sizeof(buffer), " [%02d]", pl->m_Id);
192 if ((plapi = pl->m_API))
194 plname = IS_STR_FILLED(plapi->GetName()) ? plapi->GetName() : pl->m_File.c_str();
195 len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " %s", plname);
197 if (IS_STR_FILLED(plapi->GetVersion()))
199 len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " (%s)", plapi->GetVersion());
201 if (IS_STR_FILLED(plapi->GetAuthor()))
203 UTIL_Format(&buffer[len], sizeof(buffer)-len, " by %s", plapi->GetAuthor());
207 CONMSG("%s\n", buffer);
212 else if (strcmp(command, "cmds") == 0)
216 int id = atoi(info->GetArg(2));
217 CPluginManager::CPlugin *pl = g_PluginMngr.FindById(id);
221 CONMSG("Plugin %d not found.\n", id);
227 CONMSG("Plugin %d is not loaded.\n", id);
231 CONMSG("Console commands for %s:\n", pl->m_API->GetName());
232 List<ConCommandBase *>::iterator ci;
235 for (ci=pl->m_Cmds.begin(); ci!=pl->m_Cmds.end(); ci++)
238 CONMSG(" [%5d] %-s\n", count, (*ci)->GetName());
244 CONMSG("Usage: meta cmds <id>\n");
249 else if (strcmp(command, "cvars") == 0)
253 int id = atoi(info->GetArg(2));
254 CPluginManager::CPlugin *pl = g_PluginMngr.FindById(id);
258 CONMSG("Plugin %d not found.\n", id);
264 CONMSG("Plugin %d is not loaded.\n", id);
268 CONMSG("Registered cvars for %s:\n", pl->m_API->GetName());
269 List<ConCommandBase *>::iterator ci;
272 for (ci=pl->m_Cvars.begin(); ci!=pl->m_Cvars.end(); ci++)
275 CONMSG(" [%5d] %-s\n", count, (*ci)->GetName());
281 CONMSG("Usage: meta cvars <id>\n");
286 else if (strcmp(command, "info") == 0)
290 int id = atoi(info->GetArg(2));
291 CPluginManager::CPlugin *pl = g_PluginMngr.FindById(id);
294 CONMSG("Plugin %d not found.\n", id);
300 CONMSG("Plugin %d is not loaded.\n", id);
304 if (pl->m_Status == Pl_Paused)
306 CONMSG("Plugin %d is paused.\n", id);
308 else if (pl->m_Status == Pl_Running)
312 if (pl->m_API && pl->m_API->QueryRunning(run_msg, sizeof(run_msg)-1))
318 CONMSG("Plugin %d is running.\n", id);
322 CONMSG("Plugin %d is stopped: %s\n", id, run_msg);
325 CONMSG(" Name: \"%s\" by %s\n", pl->m_API->GetName(), pl->m_API->GetAuthor());
326 CONMSG(" Version: %s\n", pl->m_API->GetVersion());
327 CONMSG(" Description: %s\n", pl->m_API->GetDescription());
328 CONMSG(" License: %s\n", pl->m_API->GetLicense());
329 CONMSG(" URL: %s\n", pl->m_API->GetURL());
330 CONMSG(" Details: API %03d, Date: %s\n", pl->m_API->GetApiVersion(), pl->m_API->GetDate());
332 CONMSG("File: %s\n\n", pl->m_File.c_str());
338 CONMSG("Usage: meta info <id>\n");
343 else if (strcmp(command, "pause") == 0)
347 int id = atoi(info->GetArg(2));
351 if (!g_PluginMngr.Pause(id, error, sizeof(error)))
353 CONMSG("Pause failed: %s\n", error);
357 CONMSG("Plugin %d has been paused.\n", id);
363 CONMSG("Usage: meta pause <id>\n");
368 else if (strcmp(command, "unpause") == 0)
372 int id = atoi(info->GetArg(2));
375 if (!g_PluginMngr.Unpause(id, error, sizeof(error)))
377 CONMSG("Unpause failed: %s\n", error);
381 CONMSG("Plugin %d has been unpaused.\n", id);
387 CONMSG("Usage: meta unpause <id>\n");
392 else if (strcmp(command, "load") == 0)
396 const char *file = info->GetArg(2);
399 const char *alias = g_PluginMngr.LookupAlias(file);
405 if (file[0] == '/' || strcmp(&(file[1]), ":\\") == 0)
407 g_Metamod.PathFormat(full_path, sizeof(full_path), "%s", file);
411 const char *ext = UTIL_GetExtension(file);
412 #if defined WIN32 || defined _WIN32
413 ext = ext ? "" : ".dll";
415 ext = ext ? "" : "_i486.so";
417 g_Metamod.PathFormat(full_path,
420 g_Metamod.GetBaseDir(),
427 CPluginManager::CPlugin *pl;
429 PluginId id = g_PluginMngr.Load(full_path, Pl_Console, already, error, sizeof(error));
430 pl = g_PluginMngr.FindById(id);
431 if (!pl || id < Pl_MinId || (pl->m_Status < Pl_Paused))
433 CONMSG("Failed to load plugin %s (%s).\n", file, error);
439 CONMSG("Plugin \"%s\" loaded with id %d.\n", pl->m_API->GetName(), pl->m_Id);
441 CONMSG("Plugin \"%s\" is already loaded as %d.\n", pl->m_API->GetName(), pl->m_Id);
448 CONMSG("Usage: meta load <path>\n");
453 else if ( (strcmp(command, "alias") == 0) ||
454 (strcmp(command, "aliases") == 0) )
458 const char *alias = info->GetArg(2);
459 const char *value = info->GetArg(3);
461 g_PluginMngr.SetAlias(alias, value);
462 if (value == NULL || value[0] == '\0')
464 CONMSG("Deleted alias: %s.\n", alias);
466 CONMSG("Set alias \"%s\" to: %s\n", alias, value);
471 const char *alias = info->GetArg(2);
472 const char *value = g_PluginMngr.LookupAlias(alias);
475 CONMSG("Alias \"%s\" is set to: %s\n", alias, value);
477 CONMSG("Alias \"%s\" was not found.\n", alias);
482 List<CNameAlias *>::iterator iter, end;
485 iter = g_PluginMngr._alias_begin();
486 end = g_PluginMngr._alias_end();
490 CONMSG("%-10.9s %s\n", "Alias", "File");
492 for (; iter!=end; iter++)
495 CONMSG("%-10.9s %s\n", p->alias.c_str(), p->value.c_str());
499 CONMSG("%d aliases total.\n", total);
503 CONMSG("No aliases found.\n");
508 else if (strcmp(command, "unload") == 0)
512 const char *file = info->GetArg(2);
516 if (id == 0 && isalpha(file[0]))
519 const char *alias = g_PluginMngr.LookupAlias(file);
526 /* first check if it's a known filename */
527 if (file[0] == '/' || strcmp(&(file[1]), ":\\") == 0)
529 g_Metamod.PathFormat(full_path, sizeof(full_path), "%s", file);
533 const char *ext = UTIL_GetExtension(file);
534 #if defined WIN32 || defined _WIN32
535 ext = ext ? "" : ".dll";
537 ext = ext ? "" : "_i486.so";
539 g_Metamod.PathFormat(full_path,
542 g_Metamod.GetBaseDir(),
547 List<CPluginManager::CPlugin *>::iterator iter, end;
548 CPluginManager::CPlugin *pl;
549 iter = g_PluginMngr._begin();
550 end = g_PluginMngr._end();
551 for (; iter!=end; iter++)
554 if (strcmp(pl->m_File.c_str(), full_path) == 0)
562 CONMSG("Plugin \"%s\" not found.\n", full_path);
567 if (!g_PluginMngr.Unload(id, false, error, sizeof(error)))
569 CONMSG("Unload failed: %s\n", error);
573 CONMSG("Plugin %d unloaded.\n", id);
577 CONMSG("Usage: meta unload <id>\n");
581 else if (strcmp(command, "force_unload") == 0)
585 int id = atoi(info->GetArg(2));
588 if (!g_PluginMngr.Unload(id, false, error, sizeof(error)))
590 CONMSG("Force unload failed: %s\n", error);
594 CONMSG("Plugin %d force unloaded.\n", id);
600 CONMSG("Usage: meta force_unload <id>\n");
605 else if (strcmp(command, "clear") == 0)
607 if (!g_PluginMngr.UnloadAll())
609 CONMSG("One or more plugins resisted removal (cleaned anyway).\n");
613 CONMSG("All plugins unloaded.\n");
617 else if (strcmp(command, "retry") == 0)
621 int id = atoi(info->GetArg(2));
624 if (!g_PluginMngr.Retry(id, error, sizeof(error)))
626 CONMSG("Error reloading plugin: %s\n", error);
630 CONMSG("Plugin %d successfully reloaded.\n", id);
636 CONMSG("Usage: meta retry <id>\n");
643 CONMSG("Metamod:Source Menu\n");
644 CONMSG("usage: meta <command> [arguments]\n");
645 CONMSG(" alias - List or set an alias\n");
646 CONMSG(" clear - Unload all plugins forcefully\n");
647 CONMSG(" cmds - Show plugin commands\n");
648 CONMSG(" cvars - Show plugin cvars\n");
649 CONMSG(" credits - About Metamod:Source\n");
650 CONMSG(" force_unload - Forcefully unload a plugin\n");
651 CONMSG(" game - Information about GameDLL\n");
652 CONMSG(" info - Information about a plugin\n");
653 CONMSG(" list - List plugins\n");
654 CONMSG(" load - Load a plugin\n");
655 CONMSG(" pause - Pause a running plugin\n");
656 CONMSG(" refresh - Reparse plugins file\n");
657 CONMSG(" retry - Attempt to reload a plugin\n");
658 CONMSG(" unload - Unload a loaded plugin\n");
659 CONMSG(" unpause - Unpause a paused plugin\n");
660 CONMSG(" version - Version information\n");
665 bool Command_ClientMeta(edict_t *client, IMetamodSourceCommandInfo *info)
667 const char *cmd = info->GetArg(0);
669 if (strcmp(cmd, "meta") == 0)
671 unsigned int args = info->GetArgCount();
674 const char *subcmd = info->GetArg(1);
676 if (strcmp(subcmd, "credits") == 0)
678 CLIENT_CONMSG(client, "Metamod:Source was developed by:\n");
679 CLIENT_CONMSG(client, " SourceHook: Pavol \"PM OnoTo\" Marko\n");
680 CLIENT_CONMSG(client, " GameDLL/Plugins: David \"BAILOPAN\" Anderson\n");
681 CLIENT_CONMSG(client, " GameDLL: Scott \"Damaged Soul\" Ehlert\n");
682 CLIENT_CONMSG(client, "For more information, see the official website\n");
683 CLIENT_CONMSG(client, "http://www.metamodsource.net/\n");
687 else if(strcmp(subcmd, "version") == 0)
689 CLIENT_CONMSG(client, "Metamod:Source version %s\n", SOURCEMM_VERSION);
690 CLIENT_CONMSG(client, "Compiled on: %s\n", SOURCEMM_DATE);
691 CLIENT_CONMSG(client, "Plugin interface version: %d:%d\n", METAMOD_PLAPI_VERSION, PLAPI_MIN_VERSION);
692 CLIENT_CONMSG(client, "SourceHook version: %d:%d\n", g_SHPtr->GetIfaceVersion(), g_SHPtr->GetImplVersion());
693 CLIENT_CONMSG(client, "http://www.metamodsource.net/\n");
697 else if(strcmp(subcmd, "list") == 0)
699 CPluginManager::CPlugin *pl;
707 for (i = g_PluginMngr._begin(); i != g_PluginMngr._end(); i++, len=0)
710 if (pl && pl->m_Status == Pl_Running)
713 if (!plapi || !plapi->QueryRunning(NULL, 0))
719 len += UTIL_Format(buffer, sizeof(buffer), " [%02d]", plnum);
721 plname = IS_STR_FILLED(plapi->GetName()) ? plapi->GetName() : pl->m_File.c_str();
722 len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " %s", plname);
724 if (IS_STR_FILLED(plapi->GetVersion()))
726 len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " (%s)", plapi->GetVersion());
728 if (IS_STR_FILLED(plapi->GetAuthor()))
730 UTIL_Format(&buffer[len], sizeof(buffer)-len, " by %s", plapi->GetAuthor());
733 CLIENT_CONMSG(client, "%s\n", buffer);
739 CLIENT_CONMSG(client, "No active plugins loaded.\n");
746 CLIENT_CONMSG(client, "Metamod:Source Menu\n");
747 CLIENT_CONMSG(client, "usage: meta <command>\n");
748 CLIENT_CONMSG(client, " credits - About Metamod:Source\n");
749 CLIENT_CONMSG(client, " list - List plugins\n");
750 CLIENT_CONMSG(client, " version - Version information\n");