Move RootConsoleMenu into core/logic.
This commit is contained in:
parent
23d55dd9d5
commit
28346c99f2
@ -41,7 +41,6 @@ project.sources += [
|
||||
'ConsoleDetours.cpp',
|
||||
'vprof_tool.cpp',
|
||||
'smn_commandline.cpp',
|
||||
'RootConsoleMenu.cpp',
|
||||
]
|
||||
|
||||
for sdk_name in SM.sdks:
|
||||
|
@ -30,12 +30,12 @@
|
||||
*/
|
||||
|
||||
#include "ConCmdManager.h"
|
||||
#include "RootConsoleMenu.h"
|
||||
#include "sm_stringutil.h"
|
||||
#include "PlayerManager.h"
|
||||
#include "HalfLife2.h"
|
||||
#include "ChatTriggers.h"
|
||||
#include "logic_bridge.h"
|
||||
#include "sourcemod.h"
|
||||
|
||||
using namespace ke;
|
||||
|
||||
@ -644,7 +644,7 @@ void ConCmdManager::OnRootConsoleCommand(const char *cmdname, const ICommandArgs
|
||||
|
||||
if (!pPlugin)
|
||||
{
|
||||
rootmenu->ConsolePrint("[SM] Plugin \"%s\" was not found.", text);
|
||||
UTIL_ConsolePrint("[SM] Plugin \"%s\" was not found.", text);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -654,20 +654,20 @@ void ConCmdManager::OnRootConsoleCommand(const char *cmdname, const ICommandArgs
|
||||
PluginHookList *pList;
|
||||
if (!pPlugin->GetProperty("CommandList", (void **)&pList))
|
||||
{
|
||||
rootmenu->ConsolePrint("[SM] No commands found for: %s", plname);
|
||||
UTIL_ConsolePrint("[SM] No commands found for: %s", plname);
|
||||
return;
|
||||
}
|
||||
if (pList->empty())
|
||||
{
|
||||
rootmenu->ConsolePrint("[SM] No commands found for: %s", plname);
|
||||
UTIL_ConsolePrint("[SM] No commands found for: %s", plname);
|
||||
return;
|
||||
}
|
||||
|
||||
const char *type = NULL;
|
||||
const char *name;
|
||||
const char *help;
|
||||
rootmenu->ConsolePrint("[SM] Listing commands for: %s", plname);
|
||||
rootmenu->ConsolePrint(" %-17.16s %-8.7s %s", "[Name]", "[Type]", "[Help]");
|
||||
UTIL_ConsolePrint("[SM] Listing commands for: %s", plname);
|
||||
UTIL_ConsolePrint(" %-17.16s %-8.7s %s", "[Name]", "[Type]", "[Help]");
|
||||
for (PluginHookList::iterator iter = pList->begin(); iter != pList->end(); iter++)
|
||||
{
|
||||
CmdHook *hook = *iter;
|
||||
@ -681,11 +681,11 @@ void ConCmdManager::OnRootConsoleCommand(const char *cmdname, const ICommandArgs
|
||||
help = hook->helptext.chars();
|
||||
else
|
||||
help = hook->info->pCmd->GetHelpText();
|
||||
rootmenu->ConsolePrint(" %-17.16s %-12.11s %s", name, type, help);
|
||||
UTIL_ConsolePrint(" %-17.16s %-12.11s %s", name, type, help);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
rootmenu->ConsolePrint("[SM] Usage: sm cmds <plugin #>");
|
||||
UTIL_ConsolePrint("[SM] Usage: sm cmds <plugin #>");
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include <sh_vector.h>
|
||||
#include <sm_namehashset.h>
|
||||
#include "logic_bridge.h"
|
||||
#include "RootConsoleMenu.h"
|
||||
#include "sourcemod.h"
|
||||
|
||||
ConVarManager g_ConVarManager;
|
||||
|
||||
@ -360,7 +360,7 @@ void ConVarManager::OnRootConsoleCommand(const char *cmdname, const ICommandArgs
|
||||
|
||||
if (!plugin)
|
||||
{
|
||||
rootmenu->ConsolePrint("[SM] Plugin \"%s\" was not found.", arg);
|
||||
UTIL_ConsolePrint("[SM] Plugin \"%s\" was not found.", arg);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -374,14 +374,14 @@ void ConVarManager::OnRootConsoleCommand(const char *cmdname, const ICommandArgs
|
||||
/* If no convar list... */
|
||||
if (!plugin->GetProperty("ConVarList", (void **)&pConVarList))
|
||||
{
|
||||
rootmenu->ConsolePrint("[SM] No convars found for: %s", plname);
|
||||
UTIL_ConsolePrint("[SM] No convars found for: %s", plname);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!wantReset)
|
||||
{
|
||||
rootmenu->ConsolePrint("[SM] Listing %d convars for: %s", pConVarList->size(), plname);
|
||||
rootmenu->ConsolePrint(" %-32.31s %s", "[Name]", "[Value]");
|
||||
UTIL_ConsolePrint("[SM] Listing %d convars for: %s", pConVarList->size(), plname);
|
||||
UTIL_ConsolePrint(" %-32.31s %s", "[Name]", "[Value]");
|
||||
}
|
||||
|
||||
/* Iterate convar list and display/reset each one */
|
||||
@ -390,7 +390,7 @@ void ConVarManager::OnRootConsoleCommand(const char *cmdname, const ICommandArgs
|
||||
/*const */ConVar *pConVar = const_cast<ConVar *>(*iter);
|
||||
if (!wantReset)
|
||||
{
|
||||
rootmenu->ConsolePrint(" %-32.31s %s", pConVar->GetName(), pConVar->GetString());
|
||||
UTIL_ConsolePrint(" %-32.31s %s", pConVar->GetName(), pConVar->GetString());
|
||||
} else {
|
||||
pConVar->Revert();
|
||||
}
|
||||
@ -398,14 +398,14 @@ void ConVarManager::OnRootConsoleCommand(const char *cmdname, const ICommandArgs
|
||||
|
||||
if (wantReset)
|
||||
{
|
||||
rootmenu->ConsolePrint("[SM] Reset %d convars for: %s", pConVarList->size(), plname);
|
||||
UTIL_ConsolePrint("[SM] Reset %d convars for: %s", pConVarList->size(), plname);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Display usage of subcommand */
|
||||
rootmenu->ConsolePrint("[SM] Usage: sm cvars [reset] <plugin #>");
|
||||
UTIL_ConsolePrint("[SM] Usage: sm cvars [reset] <plugin #>");
|
||||
}
|
||||
|
||||
Handle_t ConVarManager::CreateConVar(IPluginContext *pContext, const char *name, const char *defaultVal, const char *description, int flags, bool hasMin, float min, bool hasMax, float max)
|
||||
|
@ -33,14 +33,17 @@
|
||||
#include "CoreConfig.h"
|
||||
#include "sourcemod.h"
|
||||
#include "sourcemm_api.h"
|
||||
#include "RootConsoleMenu.h"
|
||||
#include "sm_stringutil.h"
|
||||
#include "Logger.h"
|
||||
#include "frame_hooks.h"
|
||||
#include "logic_bridge.h"
|
||||
#include "compat_wrappers.h"
|
||||
#include <sourcemod_version.h>
|
||||
#include <amtl/os/am-path.h>
|
||||
#include <amtl/os/am-fsutil.h>
|
||||
#include <sh_list.h>
|
||||
|
||||
using namespace SourceHook;
|
||||
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
ConVar sm_corecfgfile("sm_corecfgfile", "addons\\sourcemod\\configs\\core.cfg", 0, "SourceMod core configuration file");
|
||||
@ -198,11 +201,11 @@ void CoreConfig::OnRootConsoleCommand(const char *cmdname, const ICommandArgs *c
|
||||
|
||||
if (res == ConfigResult_Reject)
|
||||
{
|
||||
rootmenu->ConsolePrint("[SM] Could not set config option \"%s\" to \"%s\". (%s)", option, value, error);
|
||||
UTIL_ConsolePrint("[SM] Could not set config option \"%s\" to \"%s\". (%s)", option, value, error);
|
||||
} else if (res == ConfigResult_Ignore) {
|
||||
rootmenu->ConsolePrint("[SM] No such config option \"%s\" exists.", option);
|
||||
UTIL_ConsolePrint("[SM] No such config option \"%s\" exists.", option);
|
||||
} else {
|
||||
rootmenu->ConsolePrint("[SM] Config option \"%s\" successfully set to \"%s\".", option, value);
|
||||
UTIL_ConsolePrint("[SM] Config option \"%s\" successfully set to \"%s\".", option, value);
|
||||
}
|
||||
|
||||
return;
|
||||
@ -213,15 +216,15 @@ void CoreConfig::OnRootConsoleCommand(const char *cmdname, const ICommandArgs *c
|
||||
|
||||
if (value == NULL)
|
||||
{
|
||||
rootmenu->ConsolePrint("[SM] No such config option \"%s\" exists.", option);
|
||||
UTIL_ConsolePrint("[SM] No such config option \"%s\" exists.", option);
|
||||
} else {
|
||||
rootmenu->ConsolePrint("[SM] Config option \"%s\" is set to \"%s\".", option, value);
|
||||
UTIL_ConsolePrint("[SM] Config option \"%s\" is set to \"%s\".", option, value);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
rootmenu->ConsolePrint("[SM] Usage: sm config <option> [value]");
|
||||
UTIL_ConsolePrint("[SM] Usage: sm config <option> [value]");
|
||||
}
|
||||
|
||||
void CoreConfig::Initialize()
|
||||
|
@ -77,6 +77,7 @@ binary.sources += [
|
||||
'smn_menus.cpp',
|
||||
'sprintf.cpp',
|
||||
'LibrarySys.cpp',
|
||||
'RootConsoleMenu.cpp',
|
||||
]
|
||||
if builder.target_platform == 'windows':
|
||||
binary.sources += ['thread/WinThreads.cpp']
|
||||
|
@ -25,14 +25,10 @@
|
||||
// exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
// or <http://www.sourcemod.net/license.php>.
|
||||
#include "RootConsoleMenu.h"
|
||||
#include "sm_stringutil.h"
|
||||
#include "CoreConfig.h"
|
||||
#include "ConVarManager.h"
|
||||
#include "logic_bridge.h"
|
||||
#include <amtl/am-string.h>
|
||||
#include <sourcemod_version.h>
|
||||
|
||||
RootConsoleMenu g_RootMenu;
|
||||
IRootConsole *rootmenu = &g_RootMenu;
|
||||
|
||||
RootConsoleMenu::RootConsoleMenu()
|
||||
{
|
||||
@ -69,7 +65,7 @@ void RootConsoleMenu::ConsolePrint(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
UTIL_ConsolePrintVa(fmt, ap);
|
||||
smcore.ConsolePrintVa(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
@ -149,7 +145,7 @@ void RootConsoleMenu::DrawGenericOption(const char *cmd, const char *text)
|
||||
char buffer[255];
|
||||
size_t len, cmdlen = strlen(cmd);
|
||||
|
||||
len = UTIL_Format(buffer, sizeof(buffer), " %s", cmd);
|
||||
len = ke::SafeSprintf(buffer, sizeof(buffer), " %s", cmd);
|
||||
if (cmdlen < 16)
|
||||
{
|
||||
size_t num = 16 - cmdlen;
|
@ -27,12 +27,10 @@
|
||||
#ifndef _INCLUDE_SOURCEMOD_ROOT_CONSOLE_MENU_IMPL_H_
|
||||
#define _INCLUDE_SOURCEMOD_ROOT_CONSOLE_MENU_IMPL_H_
|
||||
|
||||
#include "sourcemod.h"
|
||||
#include "common_logic.h"
|
||||
#include <IRootConsoleMenu.h>
|
||||
#include "sourcemm_api.h"
|
||||
#include <sh_list.h>
|
||||
#include <sh_string.h>
|
||||
#include <compat_wrappers.h>
|
||||
#include <sm_namehashset.h>
|
||||
|
||||
using namespace SourceMod;
|
||||
@ -86,6 +84,5 @@ private:
|
||||
};
|
||||
|
||||
extern RootConsoleMenu g_RootMenu;
|
||||
extern IRootConsole *rootmenu;
|
||||
|
||||
#endif // _INCLUDE_SOURCEMOD_ROOT_CONSOLE_MENU_IMPL_H_
|
@ -53,6 +53,7 @@
|
||||
#include "Logger.h"
|
||||
#include "sprintf.h"
|
||||
#include "LibrarySys.h"
|
||||
#include "RootConsoleMenu.h"
|
||||
|
||||
sm_core_t smcore;
|
||||
IHandleSys *handlesys = &g_HandleSys;
|
||||
@ -63,7 +64,7 @@ ILibrarySys *libsys = &g_LibSys;
|
||||
ITextParsers *textparser = &g_TextParser;
|
||||
IVEngineServer *engine;
|
||||
IShareSys *sharesys = &g_ShareSys;
|
||||
IRootConsole *rootmenu;
|
||||
IRootConsole *rootmenu = &g_RootMenu;
|
||||
IPluginManager *pluginsys = g_PluginSys.GetOldAPI();
|
||||
IForwardManager *forwardsys = &g_Forwards;
|
||||
ITimerSystem *timersys;
|
||||
@ -120,6 +121,11 @@ static void RegisterProfiler(IProfilingTool *tool)
|
||||
g_ProfileToolManager.RegisterTool(tool);
|
||||
}
|
||||
|
||||
static void OnRootCommand(const ICommandArgs *args)
|
||||
{
|
||||
g_RootMenu.GotRootCmd(args);
|
||||
}
|
||||
|
||||
static sm_logic_t logic =
|
||||
{
|
||||
NULL,
|
||||
@ -140,6 +146,7 @@ static sm_logic_t logic =
|
||||
DumpHandles,
|
||||
DumpAdminCache,
|
||||
RegisterProfiler,
|
||||
OnRootCommand,
|
||||
&g_PluginSys,
|
||||
&g_ShareSys,
|
||||
&g_Extensions,
|
||||
@ -148,6 +155,7 @@ static sm_logic_t logic =
|
||||
&g_Admins,
|
||||
NULL,
|
||||
&g_Logger,
|
||||
&g_RootMenu,
|
||||
-1.0f
|
||||
};
|
||||
|
||||
@ -161,7 +169,6 @@ static void logic_init(const sm_core_t* core, sm_logic_t* _logic)
|
||||
|
||||
engine = core->engine;
|
||||
g_pSM = core->sm;
|
||||
rootmenu = core->rootmenu;
|
||||
timersys = core->timersys;
|
||||
playerhelpers = core->playerhelpers;
|
||||
gamehelpers = core->gamehelpers;
|
||||
|
@ -52,7 +52,7 @@ using namespace SourceHook;
|
||||
* Add 1 to the RHS of this expression to bump the intercom file
|
||||
* This is to prevent mismatching core/logic binaries
|
||||
*/
|
||||
#define SM_LOGIC_MAGIC (0x0F47C0DE - 37)
|
||||
#define SM_LOGIC_MAGIC (0x0F47C0DE - 38)
|
||||
|
||||
#if defined SM_LOGIC
|
||||
class IVEngineServer
|
||||
@ -120,6 +120,7 @@ namespace SourceMod
|
||||
class ITranslator;
|
||||
class IGameConfig;
|
||||
class IMenuManager;
|
||||
class ICommandArgs;
|
||||
}
|
||||
|
||||
class IVEngineServer;
|
||||
@ -283,7 +284,6 @@ struct sm_core_t
|
||||
IVEngineServer *engine;
|
||||
IFileSystem *filesystem;
|
||||
IPlayerInfo_Logic *playerInfo;
|
||||
IRootConsole *rootmenu;
|
||||
ITimerSystem *timersys;
|
||||
IPlayerManager *playerhelpers;
|
||||
IGameHelpers *gamehelpers;
|
||||
@ -348,6 +348,7 @@ struct sm_logic_t
|
||||
void (*DumpHandles)(void (*dumpfn)(const char *fmt, ...));
|
||||
bool (*DumpAdminCache)(const char *filename);
|
||||
void (*RegisterProfiler)(IProfilingTool *tool);
|
||||
void (*OnRootCommand)(const ICommandArgs *args);
|
||||
IScriptManager *scripts;
|
||||
IShareSys *sharesys;
|
||||
IExtensionSys *extsys;
|
||||
@ -356,6 +357,7 @@ struct sm_logic_t
|
||||
IAdminSystem *adminsys;
|
||||
IdentityToken_t *core_ident;
|
||||
ILogger *logger;
|
||||
IRootConsole *rootmenu;
|
||||
float sentinel;
|
||||
};
|
||||
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include "logic/intercom.h"
|
||||
#include "sm_stringutil.h"
|
||||
#include "Logger.h"
|
||||
#include "RootConsoleMenu.h"
|
||||
#include "TimerSys.h"
|
||||
#include "logic_bridge.h"
|
||||
#include "PlayerManager.h"
|
||||
@ -89,6 +88,7 @@ IHandleSys *handlesys;
|
||||
IForwardManager *forwardsys;
|
||||
IAdminSystem *adminsys;
|
||||
ILogger *logger;
|
||||
IRootConsole *rootmenu;
|
||||
|
||||
class VEngineServer_Logic : public IVEngineServer_Logic
|
||||
{
|
||||
@ -625,7 +625,6 @@ static sm_core_t core_bridge =
|
||||
reinterpret_cast<IVEngineServer*>(&logic_engine),
|
||||
reinterpret_cast<IFileSystem*>(&logic_filesystem),
|
||||
&logic_playerinfo,
|
||||
&g_RootMenu,
|
||||
&g_Timers,
|
||||
&g_Players,
|
||||
&g_HL2,
|
||||
@ -706,6 +705,7 @@ void InitLogicBridge()
|
||||
forwardsys = logicore.forwardsys;
|
||||
adminsys = logicore.adminsys;
|
||||
logger = logicore.logger;
|
||||
rootmenu = logicore.rootmenu;
|
||||
}
|
||||
|
||||
bool StartLogicBridge(char *error, size_t maxlength)
|
||||
|
@ -49,5 +49,6 @@ extern IHandleSys *handlesys;
|
||||
extern IForwardManager *forwardsys;
|
||||
extern IAdminSystem *adminsys;
|
||||
extern ILogger *logger;
|
||||
extern IRootConsole *rootmenu;
|
||||
|
||||
#endif /* _INCLUDE_SOURCEMOD_LOGIC_BRIDGE_H_ */
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include "sourcemm_api.h"
|
||||
#include "logic_bridge.h"
|
||||
#include "sm_globals.h"
|
||||
#include "RootConsoleMenu.h"
|
||||
#include "CoreConfig.h"
|
||||
#include <compat_wrappers.h>
|
||||
#include <ITranslator.h>
|
||||
@ -112,7 +111,7 @@ CON_COMMAND(sm, "SourceMod Menu")
|
||||
|
||||
}
|
||||
|
||||
g_RootMenu.GotRootCmd(&cargs);
|
||||
logicore.OnRootCommand(&cargs);
|
||||
}
|
||||
|
||||
FILE *g_pHndlLog = NULL;
|
||||
@ -150,7 +149,7 @@ CON_COMMAND(sm_dump_handles, "Dumps Handle usage to a file for finding Handle le
|
||||
#endif
|
||||
if (args.ArgC() < 2)
|
||||
{
|
||||
rootmenu->ConsolePrint("Usage: sm_dump_handles <file> or <log> for game logs");
|
||||
UTIL_ConsolePrint("Usage: sm_dump_handles <file> or <log> for game logs");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -163,7 +162,7 @@ CON_COMMAND(sm_dump_handles, "Dumps Handle usage to a file for finding Handle le
|
||||
FILE *fp = fopen(filename, "wt");
|
||||
if (!fp)
|
||||
{
|
||||
rootmenu->ConsolePrint("Failed to open \"%s\" for writing", filename);
|
||||
UTIL_ConsolePrint("Failed to open \"%s\" for writing", filename);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -191,10 +190,10 @@ CON_COMMAND(sm_dump_admcache, "Dumps the admin cache for debugging")
|
||||
|
||||
if (!logicore.DumpAdminCache(buffer))
|
||||
{
|
||||
rootmenu->ConsolePrint("Could not open file for writing: %s", buffer);
|
||||
UTIL_ConsolePrint("Could not open file for writing: %s", buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
rootmenu->ConsolePrint("Admin cache dumped to: %s", buffer);
|
||||
UTIL_ConsolePrint("Admin cache dumped to: %s", buffer);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user