Skip to content

Commit cce4a9b

Browse files
committed
Fix provider_source_console & dota2 compilation
1 parent 03e5979 commit cce4a9b

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

core/provider/source/provider_source_console.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void SourceProvider::SourceConVarAccessor::RemoveMetamodCommands()
8282
*/
8383
bool SourceProvider::SourceConVarAccessor::InitConCommandBaseList()
8484
{
85-
char *vfunc = (char *)SH_GET_ORIG_VFNPTR_ENTRY(icvar, &ICvar::GetCommands);
85+
char *vfunc = (char *)KHook::GetVirtualFunction(&ICvar::GetCommands, icvar);
8686

8787
if (*vfunc == '\xE9')
8888
{

core/provider/source2/provider_source2.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,10 @@ IMetamodSourceProvider* provider = &g_Source2Provider;
4040

4141
CON_COMMAND_EXTERN(meta, LocalCommand_Meta, "Metamod:Source control options");
4242

43-
4443
static ISource2ServerConfig* serverconfig = NULL;
4544
INetworkServerService* netservice = NULL;
4645
IEngineServiceMgr* enginesvcmgr = NULL;
4746

48-
#ifdef SHOULD_OVERRIDE_ALLOWDEDICATED_SERVER
49-
SH_DECL_HOOK1(ISource2ServerConfig, AllowDedicatedServers, const, 0, bool, EUniverse);
50-
#endif
51-
5247
Source2Provider::Source2Provider() :
5348
m_RegisterLoopMode(&IEngineServiceMgr::RegisterLoopMode, this, &Source2Provider::Hook_RegisterLoopMode, nullptr),
5449
m_UnregisterLoopMode(&IEngineServiceMgr::UnregisterLoopMode, this, &Source2Provider::Hook_UnregisterLoopMode, nullptr),
@@ -57,6 +52,9 @@ Source2Provider::Source2Provider() :
5752
m_LoopInit(&ILoopMode::LoopInit, this, nullptr, &Source2Provider::Hook_LoopInitPost),
5853
m_LoopShutdown(&ILoopMode::LoopShutdown, this, nullptr, &Source2Provider::Hook_LoopShutdownPost),
5954
m_ClientCommand(&IServerGameClients::ClientCommand, this, &Source2Provider::Hook_ClientCommand, nullptr)
55+
#ifdef SHOULD_OVERRIDE_ALLOWDEDICATED_SERVER
56+
,m_AllowDedicatedServers(&ISource2ServerConfig::AllowDedicatedServers, this, &Source2Provider::Hook_AllowDedicatedServers, nullptr)
57+
#endif
6058
{
6159
}
6260

@@ -145,7 +143,7 @@ void Source2Provider::Notify_DLLInit_Pre(CreateInterfaceFn engineFactory,
145143
}
146144

147145
#ifdef SHOULD_OVERRIDE_ALLOWDEDICATED_SERVER
148-
SH_ADD_VPHOOK(ISource2ServerConfig, AllowDedicatedServers, serverconfig, SH_MEMBER(this, &Source2Provider::Hook_AllowDedicatedServers), false);
146+
m_AllowDedicatedServers.Configure(KHook::GetVirtualFunction(&ISource2ServerConfig::AllowDedicatedServers, serverconfig));
149147
#endif
150148

151149
m_RegisterLoopMode.Add(enginesvcmgr);
@@ -249,9 +247,9 @@ const char* Source2Provider::GetGameDescription()
249247
}
250248

251249
#ifdef SHOULD_OVERRIDE_ALLOWDEDICATED_SERVER
252-
bool Source2Provider::Hook_AllowDedicatedServers(EUniverse universe) const
250+
KHook::Return<bool> Source2Provider::Hook_AllowDedicatedServers(ISource2ServerConfig*, EUniverse universe) const
253251
{
254-
RETURN_META_VALUE(MRES_SUPERCEDE, true);
252+
return { KHook::Action::Supercede, true };
255253
}
256254
#endif
257255

core/provider/source2/provider_source2.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ class Source2Provider : public BaseProvider
7272
virtual bool IsConCommandBaseACommand(ConCommandBase* pCommand) override;
7373
public:
7474
#ifdef SHOULD_OVERRIDE_ALLOWDEDICATED_SERVER
75-
bool Hook_AllowDedicatedServers(EUniverse universe) const;
75+
KHook::Member<ISource2ServerConfig, bool, EUniverse> m_AllowDedicatedServers;
76+
bool Hook_AllowDedicatedServers(ISource2ServerConfig*, EUniverse universe) const;
7677
#endif
7778
KHook::Virtual<IEngineServiceMgr, void, const char*, ILoopModeFactory*, void **> m_RegisterLoopMode;
7879
KHook::Return<void> Hook_RegisterLoopMode(IEngineServiceMgr*, const char* pszLoopModeName, ILoopModeFactory *pLoopModeFactory, void **ppGlobalPointer);

0 commit comments

Comments
 (0)