Put the game provider in its own header.
This commit is contained in:
parent
401aa038f8
commit
23feee0e00
@ -45,6 +45,7 @@
|
||||
#include "CoreConfig.h"
|
||||
#include "ConCmdManager.h"
|
||||
#include "IDBDriver.h"
|
||||
#include "provider.h"
|
||||
#if SOURCE_ENGINE == SE_DOTA
|
||||
# include "convar_sm_dota.h"
|
||||
#elif SOURCE_ENGINE >= SE_ALIENSWARM
|
||||
@ -127,7 +128,7 @@ public:
|
||||
serverpluginhelpers->ClientCommand(pEdict, szCommand);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
} engine_wrapper;
|
||||
|
||||
class VFileSystem_Logic : public IFileSystem_Logic
|
||||
{
|
||||
@ -216,7 +217,7 @@ public:
|
||||
{
|
||||
filesystem->CreateDirHierarchy(path, pathID);
|
||||
}
|
||||
};
|
||||
} fs_wrapper;
|
||||
|
||||
class VPlayerInfo_Logic : public IPlayerInfo_Logic
|
||||
{
|
||||
@ -285,7 +286,7 @@ public:
|
||||
{
|
||||
pInfo->ChangeTeam(iTeamNum);
|
||||
}
|
||||
};
|
||||
} playerinfo_wrapper;
|
||||
|
||||
static ConVar sm_show_activity("sm_show_activity", "13", FCVAR_SPONLY, "Activity display setting (see sourcemod.cfg)");
|
||||
static ConVar sm_immunity_mode("sm_immunity_mode", "1", FCVAR_SPONLY, "Mode for deciding immunity protection");
|
||||
@ -413,69 +414,37 @@ void UTIL_ConsolePrint(const char *fmt, ...)
|
||||
|
||||
static ServerGlobals serverGlobals;
|
||||
|
||||
class CoreProviderImpl : public CoreProvider
|
||||
CoreProviderImpl sCoreProviderImpl;
|
||||
|
||||
CoreProviderImpl::CoreProviderImpl()
|
||||
{
|
||||
public:
|
||||
CoreProviderImpl()
|
||||
{
|
||||
this->sm = &g_SourceMod;
|
||||
this->engine = &engine_wrapper_;
|
||||
this->filesystem = &fs_wrapper_;
|
||||
this->playerInfo = &playerinfo_wrapper_;
|
||||
this->timersys = &g_Timers;
|
||||
this->playerhelpers = &g_Players;
|
||||
this->gamehelpers = &g_HL2;
|
||||
this->menus = &g_Menus;
|
||||
this->spe1 = &g_pSourcePawn;
|
||||
this->spe2 = &g_pSourcePawn2;
|
||||
this->GetCoreConfigValue = get_core_config_value;
|
||||
this->DoGlobalPluginLoads = do_global_plugin_loads;
|
||||
this->AreConfigsExecuted = SM_AreConfigsExecuted;
|
||||
this->ExecuteConfigs = SM_ExecuteForPlugin;
|
||||
this->GetDBInfoFromKeyValues = keyvalues_to_dbinfo;
|
||||
this->GetActivityFlags = get_activity_flags;
|
||||
this->GetImmunityMode = get_immunity_mode;
|
||||
this->UpdateAdminCmdFlags = update_admin_cmd_flags;
|
||||
this->LookForCommandAdminFlags = look_for_cmd_admin_flags;
|
||||
this->GetGlobalTarget = get_global_target;
|
||||
this->gamesuffix = GAMEFIX;
|
||||
this->serverGlobals = &::serverGlobals;
|
||||
this->serverFactory = nullptr;
|
||||
this->engineFactory = nullptr;
|
||||
this->matchmakingDSFactory = nullptr;
|
||||
this->listeners = nullptr;
|
||||
}
|
||||
|
||||
// Local functions.
|
||||
void InitializeBridge();
|
||||
bool LoadBridge(char *error, size_t maxlength);
|
||||
void ShutdownBridge();
|
||||
|
||||
// Provider implementation.
|
||||
ConVar *FindConVar(const char *name) override;
|
||||
const char *GetCvarString(ConVar *cvar) override;
|
||||
bool GetCvarBool(ConVar* cvar) override;
|
||||
bool GetGameName(char *buffer, size_t maxlength) override;
|
||||
const char *GetGameDescription() override;
|
||||
const char *GetSourceEngineName() override;
|
||||
bool SymbolsAreHidden() override;
|
||||
bool IsMapLoading() override;
|
||||
bool IsMapRunning() override;
|
||||
int MaxClients() override;
|
||||
bool DescribePlayer(int index, const char **namep, const char **authp, int *useridp) override;
|
||||
void LogToGame(const char *message) override;
|
||||
void ConPrint(const char *message) override;
|
||||
void ConsolePrintVa(const char *fmt, va_list ap) override;
|
||||
int LoadMMSPlugin(const char *file, bool *ok, char *error, size_t maxlength) override;
|
||||
void UnloadMMSPlugin(int id) override;
|
||||
|
||||
private:
|
||||
ke::Ref<ke::SharedLib> logic_;
|
||||
LogicInitFunction logic_init_;
|
||||
VEngineServer_Logic engine_wrapper_;
|
||||
VFileSystem_Logic fs_wrapper_;
|
||||
VPlayerInfo_Logic playerinfo_wrapper_;
|
||||
} sCoreProviderImpl;
|
||||
this->sm = &g_SourceMod;
|
||||
this->engine = &engine_wrapper;
|
||||
this->filesystem = &fs_wrapper;
|
||||
this->playerInfo = &playerinfo_wrapper;
|
||||
this->timersys = &g_Timers;
|
||||
this->playerhelpers = &g_Players;
|
||||
this->gamehelpers = &g_HL2;
|
||||
this->menus = &g_Menus;
|
||||
this->spe1 = &g_pSourcePawn;
|
||||
this->spe2 = &g_pSourcePawn2;
|
||||
this->GetCoreConfigValue = get_core_config_value;
|
||||
this->DoGlobalPluginLoads = do_global_plugin_loads;
|
||||
this->AreConfigsExecuted = SM_AreConfigsExecuted;
|
||||
this->ExecuteConfigs = SM_ExecuteForPlugin;
|
||||
this->GetDBInfoFromKeyValues = keyvalues_to_dbinfo;
|
||||
this->GetActivityFlags = get_activity_flags;
|
||||
this->GetImmunityMode = get_immunity_mode;
|
||||
this->UpdateAdminCmdFlags = update_admin_cmd_flags;
|
||||
this->LookForCommandAdminFlags = look_for_cmd_admin_flags;
|
||||
this->GetGlobalTarget = get_global_target;
|
||||
this->gamesuffix = GAMEFIX;
|
||||
this->serverGlobals = &::serverGlobals;
|
||||
this->serverFactory = nullptr;
|
||||
this->engineFactory = nullptr;
|
||||
this->matchmakingDSFactory = nullptr;
|
||||
this->listeners = nullptr;
|
||||
}
|
||||
|
||||
ConVar *CoreProviderImpl::FindConVar(const char *name)
|
||||
{
|
||||
|
68
core/provider.h
Normal file
68
core/provider.h
Normal file
@ -0,0 +1,68 @@
|
||||
// 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_CORE_PROVIDER_IMPL_H_
|
||||
#define _INCLUDE_SOURCEMOD_CORE_PROVIDER_IMPL_H_
|
||||
|
||||
#include "logic/intercom.h"
|
||||
#include <amtl/os/am-shared-library.h>
|
||||
|
||||
class CoreProviderImpl : public CoreProvider
|
||||
{
|
||||
public:
|
||||
CoreProviderImpl();
|
||||
|
||||
// Local functions.
|
||||
void InitializeBridge();
|
||||
bool LoadBridge(char *error, size_t maxlength);
|
||||
void ShutdownBridge();
|
||||
|
||||
// Provider implementation.
|
||||
ConVar *FindConVar(const char *name) override;
|
||||
const char *GetCvarString(ConVar *cvar) override;
|
||||
bool GetCvarBool(ConVar* cvar) override;
|
||||
bool GetGameName(char *buffer, size_t maxlength) override;
|
||||
const char *GetGameDescription() override;
|
||||
const char *GetSourceEngineName() override;
|
||||
bool SymbolsAreHidden() override;
|
||||
bool IsMapLoading() override;
|
||||
bool IsMapRunning() override;
|
||||
int MaxClients() override;
|
||||
bool DescribePlayer(int index, const char **namep, const char **authp, int *useridp) override;
|
||||
void LogToGame(const char *message) override;
|
||||
void ConPrint(const char *message) override;
|
||||
void ConsolePrintVa(const char *fmt, va_list ap) override;
|
||||
int LoadMMSPlugin(const char *file, bool *ok, char *error, size_t maxlength) override;
|
||||
void UnloadMMSPlugin(int id) override;
|
||||
|
||||
private:
|
||||
ke::Ref<ke::SharedLib> logic_;
|
||||
LogicInitFunction logic_init_;
|
||||
};
|
||||
|
||||
extern CoreProviderImpl sCoreProviderImpl;
|
||||
|
||||
#endif // _INCLUDE_SOURCEMOD_CORE_PROVIDER_IMPL_H_
|
Loading…
Reference in New Issue
Block a user