mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-03-01 22:29:15 +01:00
Tie ConVar accessor to Source 1 provider. Stub out for Source 2 provider.
This commit is contained in:
parent
c0bd8e3b87
commit
522d8f2034
@ -17,7 +17,6 @@ for sdk_name in MMS.sdks:
|
|||||||
'metamod_oslink.cpp',
|
'metamod_oslink.cpp',
|
||||||
'metamod_plugins.cpp',
|
'metamod_plugins.cpp',
|
||||||
'metamod_util.cpp',
|
'metamod_util.cpp',
|
||||||
'provider/console.cpp',
|
|
||||||
'provider/provider_base.cpp',
|
'provider/provider_base.cpp',
|
||||||
'sourcehook/sourcehook.cpp',
|
'sourcehook/sourcehook.cpp',
|
||||||
'sourcehook/sourcehook_impl_chookidman.cpp',
|
'sourcehook/sourcehook_impl_chookidman.cpp',
|
||||||
@ -31,7 +30,10 @@ for sdk_name in MMS.sdks:
|
|||||||
if sdk_name in ['dota', 'cs2']:
|
if sdk_name in ['dota', 'cs2']:
|
||||||
binary.sources += ['provider/source2/provider_source2.cpp']
|
binary.sources += ['provider/source2/provider_source2.cpp']
|
||||||
else:
|
else:
|
||||||
binary.sources += ['provider/source/provider_source.cpp']
|
binary.sources += [
|
||||||
|
'provider/source/provider_source.cpp',
|
||||||
|
'provider/source/provider_source_console.cpp'
|
||||||
|
]
|
||||||
|
|
||||||
# Source2 hack. TODO: check this more deterministically, "are we doing an x64 build?"
|
# Source2 hack. TODO: check this more deterministically, "are we doing an x64 build?"
|
||||||
if binary.compiler.target.arch == 'x86':
|
if binary.compiler.target.arch == 'x86':
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
/**
|
|
||||||
* vim: set ts=4 :
|
|
||||||
* ======================================================
|
|
||||||
* Metamod:Source
|
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC and authors.
|
|
||||||
* All rights reserved.
|
|
||||||
* ======================================================
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied warranty.
|
|
||||||
* In no event will the authors be held liable for any damages arising from
|
|
||||||
* the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software in a
|
|
||||||
* product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
|
||||||
*
|
|
||||||
* Version: $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _INCLUDE_CONSOLE_MMS_H_
|
|
||||||
#define _INCLUDE_CONSOLE_MMS_H_
|
|
||||||
|
|
||||||
#include <interface.h>
|
|
||||||
#include "convar.h"
|
|
||||||
#include <eiface.h>
|
|
||||||
#include <sh_list.h>
|
|
||||||
|
|
||||||
class SMConVarAccessor : public IConCommandBaseAccessor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bool RegisterConCommandBase(ConCommandBase *pCommand);
|
|
||||||
bool Register(ConCommandBase *pCommand);
|
|
||||||
void Unregister(ConCommandBase *pCommand);
|
|
||||||
void RemoveMetamodCommands();
|
|
||||||
#if SOURCE_ENGINE < SE_ORANGEBOX
|
|
||||||
bool InitConCommandBaseList();
|
|
||||||
private:
|
|
||||||
ConCommandBase **m_TopConCommandBase;
|
|
||||||
#endif
|
|
||||||
private:
|
|
||||||
SourceHook::List<ConCommandBase *> m_RegisteredCommands;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern SMConVarAccessor g_SMConVarAccessor;
|
|
||||||
|
|
||||||
#endif //_INCLUDE_CONSOLE_MMS_H_
|
|
||||||
|
|
@ -32,7 +32,6 @@
|
|||||||
#include <tier0/icommandline.h>
|
#include <tier0/icommandline.h>
|
||||||
#include "../metamod_util.h"
|
#include "../metamod_util.h"
|
||||||
#include "provider_base.h"
|
#include "provider_base.h"
|
||||||
#include "console.h"
|
|
||||||
#include "metamod_console.h"
|
#include "metamod_console.h"
|
||||||
#include <filesystem.h>
|
#include <filesystem.h>
|
||||||
#include "metamod.h"
|
#include "metamod.h"
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "provider_source.h"
|
#include "provider_source.h"
|
||||||
#include "../console.h"
|
|
||||||
#include <metamod.h>
|
#include <metamod.h>
|
||||||
#include <metamod_util.h>
|
#include <metamod_util.h>
|
||||||
#include <metamod_console.h>
|
#include <metamod_console.h>
|
||||||
@ -99,7 +98,7 @@ void SourceProvider::Notify_DLLInit_Pre(CreateInterfaceFn engineFactory,
|
|||||||
g_pCVar = icvar;
|
g_pCVar = icvar;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_SMConVarAccessor.RegisterConCommandBase(&meta_local_cmd);
|
m_ConVarAccessor.RegisterConCommandBase(&meta_local_cmd);
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_EPISODEONE
|
#if SOURCE_ENGINE == SE_EPISODEONE
|
||||||
/* The Ship is the only game known at this time that uses the pre-Episode One engine */
|
/* The Ship is the only game known at this time that uses the pre-Episode One engine */
|
||||||
@ -133,7 +132,7 @@ void SourceProvider::Notify_DLLShutdown_Pre()
|
|||||||
SH_REMOVE_HOOK(IServerGameDLL, LevelInit, server, SH_MEMBER(this, &SourceProvider::Hook_LevelInit), true);
|
SH_REMOVE_HOOK(IServerGameDLL, LevelInit, server, SH_MEMBER(this, &SourceProvider::Hook_LevelInit), true);
|
||||||
SH_REMOVE_HOOK(IServerGameDLL, LevelShutdown, server, SH_MEMBER(this, &SourceProvider::Hook_LevelShutdown), true);
|
SH_REMOVE_HOOK(IServerGameDLL, LevelShutdown, server, SH_MEMBER(this, &SourceProvider::Hook_LevelShutdown), true);
|
||||||
|
|
||||||
g_SMConVarAccessor.RemoveMetamodCommands();
|
m_ConVarAccessor.RemoveMetamodCommands();
|
||||||
|
|
||||||
#if SOURCE_ENGINE < SE_ORANGEBOX
|
#if SOURCE_ENGINE < SE_ORANGEBOX
|
||||||
if (g_Metamod.IsLoadedAsGameDLL())
|
if (g_Metamod.IsLoadedAsGameDLL())
|
||||||
@ -362,17 +361,17 @@ bool SourceProvider::IsConCommandBaseACommand(ConCommandBase* pCommand)
|
|||||||
|
|
||||||
IConCommandBaseAccessor* SourceProvider::GetConCommandBaseAccessor()
|
IConCommandBaseAccessor* SourceProvider::GetConCommandBaseAccessor()
|
||||||
{
|
{
|
||||||
return &g_SMConVarAccessor;
|
return &m_ConVarAccessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SourceProvider::RegisterConCommandBase(ConCommandBase* pCommand)
|
bool SourceProvider::RegisterConCommandBase(ConCommandBase* pCommand)
|
||||||
{
|
{
|
||||||
return g_SMConVarAccessor.Register(pCommand);
|
return m_ConVarAccessor.Register(pCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SourceProvider::UnregisterConCommandBase(ConCommandBase* pCommand)
|
void SourceProvider::UnregisterConCommandBase(ConCommandBase* pCommand)
|
||||||
{
|
{
|
||||||
return g_SMConVarAccessor.Unregister(pCommand);
|
return m_ConVarAccessor.Unregister(pCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConVar* SourceProvider::CreateConVar(const char* name,
|
ConVar* SourceProvider::CreateConVar(const char* name,
|
||||||
@ -392,7 +391,7 @@ ConVar* SourceProvider::CreateConVar(const char* name,
|
|||||||
|
|
||||||
ConVar* pVar = new ConVar(name, defval, newflags, help);
|
ConVar* pVar = new ConVar(name, defval, newflags, help);
|
||||||
|
|
||||||
g_SMConVarAccessor.RegisterConCommandBase(pVar);
|
m_ConVarAccessor.RegisterConCommandBase(pVar);
|
||||||
|
|
||||||
return pVar;
|
return pVar;
|
||||||
}
|
}
|
||||||
|
@ -31,10 +31,11 @@
|
|||||||
#include "../provider_base.h"
|
#include "../provider_base.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <sh_list.h>
|
||||||
|
|
||||||
class SourceProvider : public BaseProvider
|
class SourceProvider : public BaseProvider
|
||||||
{
|
{
|
||||||
public:
|
public: // BaseProvider
|
||||||
virtual void Notify_DLLInit_Pre(CreateInterfaceFn engineFactory, CreateInterfaceFn serverFactory) override;
|
virtual void Notify_DLLInit_Pre(CreateInterfaceFn engineFactory, CreateInterfaceFn serverFactory) override;
|
||||||
virtual void Notify_DLLShutdown_Pre() override;
|
virtual void Notify_DLLShutdown_Pre() override;
|
||||||
virtual bool ProcessVDF(const char* file, char path[], size_t path_len, char alias[], size_t alias_len) override;
|
virtual bool ProcessVDF(const char* file, char path[], size_t path_len, char alias[], size_t alias_len) override;
|
||||||
@ -58,7 +59,25 @@ public:
|
|||||||
virtual int GetUserMessageCount() override;
|
virtual int GetUserMessageCount() override;
|
||||||
virtual int FindUserMessage(const char* name, int* size = nullptr) override;
|
virtual int FindUserMessage(const char* name, int* size = nullptr) override;
|
||||||
virtual const char* GetUserMessage(int index, int* size = nullptr) override;
|
virtual const char* GetUserMessage(int index, int* size = nullptr) override;
|
||||||
public: // Hook callbacks that map to provider callbacks
|
public: // IConCommandBaseAccessor
|
||||||
|
class SourceConVarAccessor : public IConCommandBaseAccessor
|
||||||
|
{
|
||||||
|
virtual bool RegisterConCommandBase(ConCommandBase* pCommand) override;
|
||||||
|
private:
|
||||||
|
bool Register(ConCommandBase* pCommand);
|
||||||
|
void Unregister(ConCommandBase* pCommand);
|
||||||
|
void RemoveMetamodCommands();
|
||||||
|
#if SOURCE_ENGINE < SE_ORANGEBOX
|
||||||
|
bool InitConCommandBaseList();
|
||||||
|
private:
|
||||||
|
ConCommandBase** m_TopConCommandBase = nullptr;
|
||||||
|
#endif
|
||||||
|
private:
|
||||||
|
SourceHook::List<ConCommandBase*> m_RegisteredCommands;
|
||||||
|
|
||||||
|
friend class SourceProvider;
|
||||||
|
} m_ConVarAccessor;
|
||||||
|
public:
|
||||||
bool Hook_GameInit();
|
bool Hook_GameInit();
|
||||||
bool Hook_LevelInit(char const* pMapName, char const* pMapEntities, char const* pOldLevel,
|
bool Hook_LevelInit(char const* pMapName, char const* pMapEntities, char const* pOldLevel,
|
||||||
char const* pLandmarkName, bool loadGame, bool background);
|
char const* pLandmarkName, bool loadGame, bool background);
|
||||||
|
@ -25,20 +25,14 @@
|
|||||||
* Version: $Id$
|
* Version: $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "console.h"
|
#include "provider_source.h"
|
||||||
#include "provider_base.h"
|
|
||||||
#include "metamod_util.h"
|
|
||||||
|
|
||||||
using namespace SourceHook;
|
|
||||||
|
|
||||||
SMConVarAccessor g_SMConVarAccessor;
|
|
||||||
|
|
||||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
#else
|
#else
|
||||||
#define RegisterConCommand RegisterConCommandBase
|
#define RegisterConCommand RegisterConCommandBase
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool SMConVarAccessor::RegisterConCommandBase(ConCommandBase *pCommand)
|
bool SourceProvider::SourceConVarAccessor::RegisterConCommandBase(ConCommandBase *pCommand)
|
||||||
{
|
{
|
||||||
m_RegisteredCommands.push_back(pCommand);
|
m_RegisteredCommands.push_back(pCommand);
|
||||||
#if SOURCE_ENGINE < SE_ALIENSWARM
|
#if SOURCE_ENGINE < SE_ALIENSWARM
|
||||||
@ -49,7 +43,7 @@ bool SMConVarAccessor::RegisterConCommandBase(ConCommandBase *pCommand)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SMConVarAccessor::Register(ConCommandBase *pCommand)
|
bool SourceProvider::SourceConVarAccessor::Register(ConCommandBase *pCommand)
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE < SE_ALIENSWARM
|
#if SOURCE_ENGINE < SE_ALIENSWARM
|
||||||
pCommand->SetNext(NULL);
|
pCommand->SetNext(NULL);
|
||||||
@ -59,7 +53,7 @@ bool SMConVarAccessor::Register(ConCommandBase *pCommand)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SMConVarAccessor::RemoveMetamodCommands()
|
void SourceProvider::SourceConVarAccessor::RemoveMetamodCommands()
|
||||||
{
|
{
|
||||||
List<ConCommandBase *>::iterator iter;
|
List<ConCommandBase *>::iterator iter;
|
||||||
|
|
||||||
@ -87,7 +81,7 @@ void SMConVarAccessor::RemoveMetamodCommands()
|
|||||||
* This craziness eliminates the need for the eternal command/cvar used previously which
|
* This craziness eliminates the need for the eternal command/cvar used previously which
|
||||||
* could have caused a crash as a result of registering commands/cvars more than once.
|
* could have caused a crash as a result of registering commands/cvars more than once.
|
||||||
*/
|
*/
|
||||||
bool SMConVarAccessor::InitConCommandBaseList()
|
bool SourceProvider::SourceConVarAccessor::InitConCommandBaseList()
|
||||||
{
|
{
|
||||||
char *vfunc = (char *)SH_GET_ORIG_VFNPTR_ENTRY(icvar, &ICvar::GetCommands);
|
char *vfunc = (char *)SH_GET_ORIG_VFNPTR_ENTRY(icvar, &ICvar::GetCommands);
|
||||||
|
|
||||||
@ -140,7 +134,7 @@ bool SMConVarAccessor::InitConCommandBaseList()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void SMConVarAccessor::Unregister(ConCommandBase *pCommand)
|
void SourceProvider::SourceConVarAccessor::Unregister(ConCommandBase *pCommand)
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
icvar->UnregisterConCommand(pCommand);
|
icvar->UnregisterConCommand(pCommand);
|
||||||
@ -183,4 +177,3 @@ void SMConVarAccessor::Unregister(ConCommandBase *pCommand)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
@ -24,7 +24,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "provider_source2.h"
|
#include "provider_source2.h"
|
||||||
#include "../console.h"
|
|
||||||
#include <metamod.h>
|
#include <metamod.h>
|
||||||
#include <metamod_util.h>
|
#include <metamod_util.h>
|
||||||
#include <metamod_console.h>
|
#include <metamod_console.h>
|
||||||
@ -122,7 +121,9 @@ void Source2Provider::Notify_DLLInit_Pre(CreateInterfaceFn engineFactory,
|
|||||||
|
|
||||||
g_pCVar = icvar;
|
g_pCVar = icvar;
|
||||||
|
|
||||||
|
#ifdef S2_CONVAR_UNFINISHED
|
||||||
g_SMConVarAccessor.RegisterConCommandBase(&meta_local_cmd);
|
g_SMConVarAccessor.RegisterConCommandBase(&meta_local_cmd);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (gameclients)
|
if (gameclients)
|
||||||
{
|
{
|
||||||
@ -139,7 +140,9 @@ void Source2Provider::Notify_DLLInit_Pre(CreateInterfaceFn engineFactory,
|
|||||||
|
|
||||||
void Source2Provider::Notify_DLLShutdown_Pre()
|
void Source2Provider::Notify_DLLShutdown_Pre()
|
||||||
{
|
{
|
||||||
|
#ifdef S2_CONVAR_UNFINISHED
|
||||||
g_SMConVarAccessor.RemoveMetamodCommands();
|
g_SMConVarAccessor.RemoveMetamodCommands();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Source2Provider::ProcessVDF(const char* file, char path[], size_t path_len, char alias[], size_t alias_len)
|
bool Source2Provider::ProcessVDF(const char* file, char path[], size_t path_len, char alias[], size_t alias_len)
|
||||||
@ -241,37 +244,57 @@ void Source2Provider::ServerCommand(const char* cmd)
|
|||||||
|
|
||||||
const char* Source2Provider::GetConVarString(ConVar* convar)
|
const char* Source2Provider::GetConVarString(ConVar* convar)
|
||||||
{
|
{
|
||||||
|
#ifdef S2_CONVAR_UNFINISHED
|
||||||
if (convar == NULL)
|
if (convar == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return convar->GetString();
|
return convar->GetString();
|
||||||
|
#else
|
||||||
|
return "";
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Source2Provider::SetConVarString(ConVar* convar, const char* str)
|
void Source2Provider::SetConVarString(ConVar* convar, const char* str)
|
||||||
{
|
{
|
||||||
|
#ifdef S2_CONVAR_UNFINISHED
|
||||||
convar->SetValue(str);
|
convar->SetValue(str);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Source2Provider::IsConCommandBaseACommand(ConCommandBase* pCommand)
|
bool Source2Provider::IsConCommandBaseACommand(ConCommandBase* pCommand)
|
||||||
{
|
{
|
||||||
|
#ifdef S2_CONVAR_UNFINISHED
|
||||||
return pCommand->IsCommand();
|
return pCommand->IsCommand();
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
IConCommandBaseAccessor* Source2Provider::GetConCommandBaseAccessor()
|
IConCommandBaseAccessor* Source2Provider::GetConCommandBaseAccessor()
|
||||||
{
|
{
|
||||||
|
#ifdef S2_CONVAR_UNFINISHED
|
||||||
return &g_SMConVarAccessor;
|
return &g_SMConVarAccessor;
|
||||||
|
#else
|
||||||
|
return nullptr;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Source2Provider::RegisterConCommandBase(ConCommandBase* pCommand)
|
bool Source2Provider::RegisterConCommandBase(ConCommandBase* pCommand)
|
||||||
{
|
{
|
||||||
|
#ifdef S2_CONVAR_UNFINISHED
|
||||||
return g_SMConVarAccessor.Register(pCommand);
|
return g_SMConVarAccessor.Register(pCommand);
|
||||||
|
#else
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Source2Provider::UnregisterConCommandBase(ConCommandBase* pCommand)
|
void Source2Provider::UnregisterConCommandBase(ConCommandBase* pCommand)
|
||||||
{
|
{
|
||||||
|
#ifdef S2_CONVAR_UNFINISHED
|
||||||
return g_SMConVarAccessor.Unregister(pCommand);
|
return g_SMConVarAccessor.Unregister(pCommand);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ConVar* Source2Provider::CreateConVar(const char* name,
|
ConVar* Source2Provider::CreateConVar(const char* name,
|
||||||
@ -279,6 +302,7 @@ ConVar* Source2Provider::CreateConVar(const char* name,
|
|||||||
const char* help,
|
const char* help,
|
||||||
int flags)
|
int flags)
|
||||||
{
|
{
|
||||||
|
#ifdef S2_CONVAR_UNFINISHED
|
||||||
int newflags = 0;
|
int newflags = 0;
|
||||||
if (flags & ConVarFlag_Notify)
|
if (flags & ConVarFlag_Notify)
|
||||||
{
|
{
|
||||||
@ -294,6 +318,9 @@ ConVar* Source2Provider::CreateConVar(const char* name,
|
|||||||
g_SMConVarAccessor.RegisterConCommandBase(pVar);
|
g_SMConVarAccessor.RegisterConCommandBase(pVar);
|
||||||
|
|
||||||
return pVar;
|
return pVar;
|
||||||
|
#else
|
||||||
|
return nullptr;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
class GlobCommand : public IMetamodSourceCommandInfo
|
class GlobCommand : public IMetamodSourceCommandInfo
|
||||||
|
Loading…
x
Reference in New Issue
Block a user