From 32ba03538b0234ddfb502c66ecfc907e5ef14553 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 29 Aug 2015 23:44:07 -0400 Subject: [PATCH] Move CCommandArgs into its own header. --- core/command_args.h | 77 +++++++++++++++++++++++++++++++++++++++++++++ core/logic_bridge.h | 4 --- core/sm_srvcmds.cpp | 47 ++------------------------- core/sourcemod.cpp | 7 +++-- 4 files changed, 83 insertions(+), 52 deletions(-) create mode 100644 core/command_args.h diff --git a/core/command_args.h b/core/command_args.h new file mode 100644 index 00000000..213bef86 --- /dev/null +++ b/core/command_args.h @@ -0,0 +1,77 @@ +// vim: set ts=4 sw=4 tw=99 noet : +// ============================================================================= +// SourceMod +// Copyright (C) 2004-2015 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 . +// +// 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 . +#ifndef _INCLUDE_SOURCEMOD_CCOMMANDARGS_IMPL_H_ +#define _INCLUDE_SOURCEMOD_CCOMMANDARGS_IMPL_H_ + +#include "sourcemm_api.h" +#include +#include + +#if SOURCE_ENGINE==SE_EPISODEONE || SOURCE_ENGINE==SE_DARKMESSIAH +class EngineArgs : public ICommandArgs +{ +public: + EngineArgs(const CCommand& _cmd) + { + } + const char *Arg(int n) const + { + return engine->Cmd_Argv(n); + } + int ArgC() const + { + return engine->Cmd_Argc(); + } + const char *ArgS() const + { + return engine->Cmd_Args(); + } +}; +#else +class EngineArgs : public ICommandArgs +{ + const CCommand *cmd; +public: + EngineArgs(const CCommand& _cmd) : cmd(&_cmd) + { + } + const char *Arg(int n) const + { + return cmd->Arg(n); + } + int ArgC() const + { + return cmd->ArgC(); + } + const char *ArgS() const + { + return cmd->ArgS(); + } +}; +#endif + +#endif // _INCLUDE_SOURCEMOD_CCOMMANDARGS_IMPL_H_ diff --git a/core/logic_bridge.h b/core/logic_bridge.h index 011125a5..2838be42 100644 --- a/core/logic_bridge.h +++ b/core/logic_bridge.h @@ -33,10 +33,6 @@ #include "logic/intercom.h" -void InitLogicBridge(); -bool StartLogicBridge(char *error, size_t maxlength); -void ShutdownLogicBridge(); - struct sm_logic_t; extern sm_logic_t logicore; diff --git a/core/sm_srvcmds.cpp b/core/sm_srvcmds.cpp index e762047d..c3d01f49 100644 --- a/core/sm_srvcmds.cpp +++ b/core/sm_srvcmds.cpp @@ -33,59 +33,16 @@ #include "logic_bridge.h" #include "sm_globals.h" #include "CoreConfig.h" -#include +#include "command_args.h" #include #include -#if SOURCE_ENGINE==SE_EPISODEONE || SOURCE_ENGINE==SE_DARKMESSIAH -class CCommandArgs : public ICommandArgs -{ -public: - CCommandArgs(const CCommand& _cmd) - { - } - const char *Arg(int n) const - { - return engine->Cmd_Argv(n); - } - int ArgC() const - { - return engine->Cmd_Argc(); - } - const char *ArgS() const - { - return engine->Cmd_Args(); - } -}; -#else -class CCommandArgs : public ICommandArgs -{ - const CCommand *cmd; -public: - CCommandArgs(const CCommand& _cmd) : cmd(&_cmd) - { - } - const char *Arg(int n) const - { - return cmd->Arg(n); - } - int ArgC() const - { - return cmd->ArgC(); - } - const char *ArgS() const - { - return cmd->ArgS(); - } -}; -#endif - CON_COMMAND(sm, "SourceMod Menu") { #if SOURCE_ENGINE <= SE_DARKMESSIAH CCommand args; #endif - CCommandArgs cargs(args); + EngineArgs cargs(args); if (cargs.ArgC() >= 2) { const char *cmdname = cargs.Arg(1); diff --git a/core/sourcemod.cpp b/core/sourcemod.cpp index 3c737197..eb6d9e95 100644 --- a/core/sourcemod.cpp +++ b/core/sourcemod.cpp @@ -41,6 +41,7 @@ #include #include "frame_hooks.h" #include "logic_bridge.h" +#include "provider.h" #include #include @@ -168,7 +169,7 @@ bool SourceModBase::InitializeSourceMod(char *error, size_t maxlength, bool late ke::path::Format(m_SMBaseDir, sizeof(m_SMBaseDir), "%s/%s", g_BaseDir.c_str(), basepath); ke::path::Format(m_SMRelDir, sizeof(m_SMRelDir), "%s", basepath); - if (!StartLogicBridge(error, maxlength)) + if (!sCoreProviderImpl.LoadBridge(error, maxlength)) { return false; } @@ -252,7 +253,7 @@ void SourceModBase::StartSourceMod(bool late) enginePatch = SH_GET_CALLCLASS(engine); gamedllPatch = SH_GET_CALLCLASS(gamedll); - InitLogicBridge(); + sCoreProviderImpl.InitializeBridge(); /* Initialize CoreConfig to get the SourceMod base path properly - this parses core.cfg */ g_CoreConfig.Initialize(); @@ -486,7 +487,7 @@ void SourceModBase::CloseSourceMod() } /* Rest In Peace */ - ShutdownLogicBridge(); + sCoreProviderImpl.ShutdownBridge(); ShutdownJIT(); }