Convert core_bridge to a proper class declaration.

This commit is contained in:
David Anderson 2015-08-29 20:19:04 -04:00
parent 3d5c9f0e21
commit 0f9e5234fe
2 changed files with 55 additions and 49 deletions

View File

@ -52,7 +52,7 @@ using namespace SourceHook;
* Add 1 to the RHS of this expression to bump the intercom file * Add 1 to the RHS of this expression to bump the intercom file
* This is to prevent mismatching core/logic binaries * This is to prevent mismatching core/logic binaries
*/ */
#define SM_LOGIC_MAGIC (0x0F47C0DE - 40) #define SM_LOGIC_MAGIC (0x0F47C0DE - 41)
#if defined SM_LOGIC #if defined SM_LOGIC
class IVEngineServer class IVEngineServer

View File

@ -608,49 +608,55 @@ void UTIL_ConsolePrint(const char *fmt, ...)
static ServerGlobals serverGlobals; static ServerGlobals serverGlobals;
static CoreProvider core_bridge = class CoreProviderImpl : public CoreProvider
{ {
/* Objects */ public:
&g_SourceMod, CoreProviderImpl()
reinterpret_cast<IVEngineServer*>(&logic_engine), {
reinterpret_cast<IFileSystem*>(&logic_filesystem), this->sm = &g_SourceMod;
&logic_playerinfo, this->engine = reinterpret_cast<IVEngineServer*>(&logic_engine);
&g_Timers, this->filesystem = reinterpret_cast<IFileSystem*>(&logic_filesystem);
&g_Players, this->playerInfo = &logic_playerinfo;
&g_HL2, this->timersys = &g_Timers;
&g_Menus, this->playerhelpers = &g_Players;
&g_pSourcePawn, this->gamehelpers = &g_HL2;
&g_pSourcePawn2, this->menus = &g_Menus;
/* Functions */ this->spe1 = &g_pSourcePawn;
find_convar, this->spe2 = &g_pSourcePawn2;
log_to_game, this->FindConVar = find_convar;
conprint, this->LogToGame = log_to_game;
get_cvar_string, this->ConPrint = conprint;
get_cvar_bool, this->GetCvarString = get_cvar_string;
get_game_name, this->GetCvarBool = get_cvar_bool;
get_game_description, this->GetGameName = get_game_name;
get_source_engine_name, this->GetGameDescription = get_game_description;
symbols_are_hidden, this->GetSourceEngineName = get_source_engine_name;
get_core_config_value, this->SymbolsAreHidden = symbols_are_hidden;
is_map_loading, this->GetCoreConfigValue = get_core_config_value;
is_map_running, this->IsMapLoading = is_map_loading;
load_mms_plugin, this->IsMapRunning = is_map_running;
unload_mms_plugin, this->LoadMMSPlugin = load_mms_plugin;
do_global_plugin_loads, this->UnloadMMSPlugin = unload_mms_plugin;
SM_AreConfigsExecuted, this->DoGlobalPluginLoads = do_global_plugin_loads;
SM_ExecuteForPlugin, this->AreConfigsExecuted = SM_AreConfigsExecuted;
keyvalues_to_dbinfo, this->ExecuteConfigs = SM_ExecuteForPlugin;
get_activity_flags, this->GetDBInfoFromKeyValues = keyvalues_to_dbinfo;
get_immunity_mode, this->GetActivityFlags = get_activity_flags;
update_admin_cmd_flags, this->GetImmunityMode = get_immunity_mode;
look_for_cmd_admin_flags, this->UpdateAdminCmdFlags = update_admin_cmd_flags;
describe_player, this->LookForCommandAdminFlags = look_for_cmd_admin_flags;
get_max_clients, this->DescribePlayer = describe_player;
get_global_target, this->MaxClients = get_max_clients;
UTIL_ConsolePrintVa, this->GetGlobalTarget = get_global_target;
GAMEFIX, this->ConsolePrintVa = UTIL_ConsolePrintVa;
&serverGlobals, this->gamesuffix = GAMEFIX;
}; this->serverGlobals = &::serverGlobals;
this->serverFactory = nullptr;
this->engineFactory = nullptr;
this->matchmakingDSFactory = nullptr;
this->listeners = nullptr;
}
} sCoreProviderImpl;
void InitLogicBridge() void InitLogicBridge()
{ {
@ -658,9 +664,9 @@ void InitLogicBridge()
serverGlobals.frametime = &gpGlobals->frametime; serverGlobals.frametime = &gpGlobals->frametime;
serverGlobals.interval_per_tick = &gpGlobals->interval_per_tick; serverGlobals.interval_per_tick = &gpGlobals->interval_per_tick;
core_bridge.engineFactory = (void *)g_SMAPI->GetEngineFactory(false); sCoreProviderImpl.engineFactory = (void *)g_SMAPI->GetEngineFactory(false);
core_bridge.serverFactory = (void *)g_SMAPI->GetServerFactory(false); sCoreProviderImpl.serverFactory = (void *)g_SMAPI->GetServerFactory(false);
core_bridge.listeners = SMGlobalClass::head; sCoreProviderImpl.listeners = SMGlobalClass::head;
char path[PLATFORM_MAX_PATH]; char path[PLATFORM_MAX_PATH];
@ -668,11 +674,11 @@ void InitLogicBridge()
if (ke::Ref<ke::SharedLib> mmlib = ke::SharedLib::Open(path, NULL, 0)) if (ke::Ref<ke::SharedLib> mmlib = ke::SharedLib::Open(path, NULL, 0))
{ {
core_bridge.matchmakingDSFactory = sCoreProviderImpl.matchmakingDSFactory =
mmlib->get<decltype(core_bridge.matchmakingDSFactory)>("CreateInterface"); mmlib->get<decltype(sCoreProviderImpl.matchmakingDSFactory)>("CreateInterface");
} }
logic_init_fn(&core_bridge, &logicore); logic_init_fn(&sCoreProviderImpl, &logicore);
/* Add SMGlobalClass instances */ /* Add SMGlobalClass instances */
SMGlobalClass* glob = SMGlobalClass::head; SMGlobalClass* glob = SMGlobalClass::head;