Move CCommandArgs into its own header.
This commit is contained in:
parent
23feee0e00
commit
32ba03538b
77
core/command_args.h
Normal file
77
core/command_args.h
Normal file
@ -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 <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>.
|
||||
#ifndef _INCLUDE_SOURCEMOD_CCOMMANDARGS_IMPL_H_
|
||||
#define _INCLUDE_SOURCEMOD_CCOMMANDARGS_IMPL_H_
|
||||
|
||||
#include "sourcemm_api.h"
|
||||
#include <IRootConsoleMenu.h>
|
||||
#include <compat_wrappers.h>
|
||||
|
||||
#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_
|
@ -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;
|
||||
|
@ -33,59 +33,16 @@
|
||||
#include "logic_bridge.h"
|
||||
#include "sm_globals.h"
|
||||
#include "CoreConfig.h"
|
||||
#include <compat_wrappers.h>
|
||||
#include "command_args.h"
|
||||
#include <ITranslator.h>
|
||||
#include <amtl/am-string.h>
|
||||
|
||||
#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);
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include <IGameConfigs.h>
|
||||
#include "frame_hooks.h"
|
||||
#include "logic_bridge.h"
|
||||
#include "provider.h"
|
||||
#include <amtl/os/am-shared-library.h>
|
||||
#include <amtl/os/am-path.h>
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user