Rename smcore to bridge, and use it as a pointer.

This commit is contained in:
David Anderson 2015-08-29 19:23:50 -04:00
parent a2dac43833
commit 3d5c9f0e21
19 changed files with 130 additions and 127 deletions

View File

@ -328,7 +328,7 @@ void AdminCache::AddCommandOverride(const char *cmd, OverrideType type, FlagBits
return;
map->insert(cmd, flags);
smcore.UpdateAdminCmdFlags(cmd, type, flags, false);
bridge->UpdateAdminCmdFlags(cmd, type, flags, false);
}
bool AdminCache::GetCommandOverride(const char *cmd, OverrideType type, FlagBits *pFlags)
@ -357,13 +357,13 @@ void AdminCache::UnsetCommandOverride(const char *cmd, OverrideType type)
void AdminCache::_UnsetCommandGroupOverride(const char *group)
{
m_CmdGrpOverrides.remove(group);
smcore.UpdateAdminCmdFlags(group, Override_CommandGroup, 0, true);
bridge->UpdateAdminCmdFlags(group, Override_CommandGroup, 0, true);
}
void AdminCache::_UnsetCommandOverride(const char *cmd)
{
m_CmdOverrides.remove(cmd);
smcore.UpdateAdminCmdFlags(cmd, Override_Command, 0, true);
bridge->UpdateAdminCmdFlags(cmd, Override_Command, 0, true);
}
void AdminCache::DumpCommandOverrideCache(OverrideType type)
@ -1516,7 +1516,7 @@ bool AdminCache::CanAdminTarget(AdminId id, AdminId target)
}
/** Fourth, if the targeted admin is immune from targeting admin. */
int mode = smcore.GetImmunityMode();
int mode = bridge->GetImmunityMode();
switch (mode)
{
case 1:
@ -1653,7 +1653,7 @@ bool AdminCache::CanAdminUseCommand(int client, const char *cmd)
cmd++;
}
if (!smcore.LookForCommandAdminFlags(cmd, &bits))
if (!bridge->LookForCommandAdminFlags(cmd, &bits))
{
if (!GetCommandOverride(cmd, otype, &bits))
{
@ -1728,7 +1728,7 @@ bool AdminCache::CheckAccess(int client, const char *cmd, FlagBits flags, bool o
bool found_command = false;
if (!override_only)
{
found_command = smcore.LookForCommandAdminFlags(cmd, &bits);
found_command = bridge->LookForCommandAdminFlags(cmd, &bits);
}
if (!found_command)

View File

@ -79,7 +79,7 @@ CLocalExtension::CLocalExtension(const char *filename)
PLATFORM_MAX_PATH,
"extensions/%s.%s." PLATFORM_LIB_EXT,
filename,
smcore.gamesuffix);
bridge->gamesuffix);
if (libsys->IsPathFile(path))
{
@ -87,9 +87,9 @@ CLocalExtension::CLocalExtension(const char *filename)
}
/* COMPAT HACK: One-halfth, if ep2v, see if there is an engine specific build in the new place with old naming */
if (strcmp(smcore.gamesuffix, "2.tf2") == 0
|| strcmp(smcore.gamesuffix, "2.dods") == 0
|| strcmp(smcore.gamesuffix, "2.hl2dm") == 0
if (strcmp(bridge->gamesuffix, "2.tf2") == 0
|| strcmp(bridge->gamesuffix, "2.dods") == 0
|| strcmp(bridge->gamesuffix, "2.hl2dm") == 0
)
{
g_pSM->BuildPath(Path_SM,
@ -103,7 +103,7 @@ CLocalExtension::CLocalExtension(const char *filename)
goto found;
}
}
else if (strcmp(smcore.gamesuffix, "2.nd") == 0)
else if (strcmp(bridge->gamesuffix, "2.nd") == 0)
{
g_pSM->BuildPath(Path_SM,
path,
@ -123,7 +123,7 @@ CLocalExtension::CLocalExtension(const char *filename)
PLATFORM_MAX_PATH,
"extensions/auto.%s/%s." PLATFORM_LIB_EXT,
filename,
smcore.gamesuffix);
bridge->gamesuffix);
/* Try the "normal" version */
if (!libsys->IsPathFile(path))
@ -192,7 +192,7 @@ bool CLocalExtension::Load(char *error, size_t maxlength)
if (m_pAPI->IsMetamodExtension())
{
bool ok;
m_PlId = smcore.LoadMMSPlugin(m_Path.c_str(), &ok, error, maxlength);
m_PlId = bridge->LoadMMSPlugin(m_Path.c_str(), &ok, error, maxlength);
if (!m_PlId || !ok)
{
@ -209,7 +209,7 @@ bool CLocalExtension::Load(char *error, size_t maxlength)
{
if (m_PlId)
{
smcore.UnloadMMSPlugin(m_PlId);
bridge->UnloadMMSPlugin(m_PlId);
m_PlId = 0;
}
}
@ -230,7 +230,7 @@ void CLocalExtension::Unload()
{
if (m_pAPI != NULL && m_PlId)
{
smcore.UnloadMMSPlugin(m_PlId);
bridge->UnloadMMSPlugin(m_PlId);
m_PlId = 0;
}
@ -293,7 +293,7 @@ bool CExtension::PerformAPICheck(char *error, size_t maxlength)
bool CExtension::Load(char *error, size_t maxlength)
{
CreateIdentity();
if (!m_pAPI->OnExtensionLoad(this, &g_ShareSys, error, maxlength, !smcore.IsMapLoading()))
if (!m_pAPI->OnExtensionLoad(this, &g_ShareSys, error, maxlength, !bridge->IsMapLoading()))
{
DestroyIdentity();
return false;
@ -301,7 +301,7 @@ bool CExtension::Load(char *error, size_t maxlength)
else
{
/* Check if we're past load time */
if (!smcore.IsMapLoading())
if (!bridge->IsMapLoading())
{
m_pAPI->OnExtensionsAllLoaded();
}

View File

@ -151,7 +151,7 @@ CGameConfig::CGameConfig(const char *file, const char *engine)
m_CustomHandler = NULL;
if (!engine)
m_pEngine = smcore.GetSourceEngineName();
m_pEngine = bridge->GetSourceEngineName();
else
m_pEngine = engine;
@ -548,11 +548,11 @@ SMCResult CGameConfig::ReadSMC_LeavingSection(const SMCStates *states)
void *addrInBase = NULL;
if (strcmp(s_TempSig.library, "server") == 0)
{
addrInBase = smcore.serverFactory;
addrInBase = bridge->serverFactory;
} else if (strcmp(s_TempSig.library, "engine") == 0) {
addrInBase = smcore.engineFactory;
addrInBase = bridge->engineFactory;
} else if (strcmp(s_TempSig.library, "matchmaking_ds") == 0) {
addrInBase = smcore.matchmakingDSFactory;
addrInBase = bridge->matchmakingDSFactory;
}
void *final_addr = NULL;
if (addrInBase == NULL)
@ -580,7 +580,7 @@ SMCResult CGameConfig::ReadSMC_LeavingSection(const SMCStates *states)
void *handle = dlopen(info.dli_fname, RTLD_NOW);
if (handle)
{
if (smcore.SymbolsAreHidden())
if (bridge->SymbolsAreHidden())
final_addr = g_MemUtils.ResolveSymbol(handle, &s_TempSig.sig[1]);
else
final_addr = dlsym(handle, &s_TempSig.sig[1]);
@ -1039,8 +1039,8 @@ void GameConfigManager::OnSourceModStartup(bool late)
LoadGameConfigFile("core.games", &g_pGameConf, NULL, 0);
strncopy(g_Game, g_pSM->GetGameFolderName(), sizeof(g_Game));
strncopy(g_GameDesc + 1, smcore.GetGameDescription(), sizeof(g_GameDesc) - 1);
smcore.GetGameName(g_GameName + 1, sizeof(g_GameName) - 1);
strncopy(g_GameDesc + 1, bridge->GetGameDescription(), sizeof(g_GameDesc) - 1);
bridge->GetGameName(g_GameName + 1, sizeof(g_GameName) - 1);
}
void GameConfigManager::OnSourceModAllInitialized()

View File

@ -262,7 +262,7 @@ void Logger::LogToOpenFileEx(FILE *fp, const char *msg, va_list ap)
return;
}
static ConVar *sv_logecho = smcore.FindConVar("sv_logecho");
static ConVar *sv_logecho = bridge->FindConVar("sv_logecho");
char buffer[3072];
ke::SafeVsprintf(buffer, sizeof(buffer), msg, ap);
@ -274,11 +274,11 @@ void Logger::LogToOpenFileEx(FILE *fp, const char *msg, va_list ap)
fprintf(fp, "L %s: %s\n", date, buffer);
if (!sv_logecho || smcore.GetCvarBool(sv_logecho))
if (!sv_logecho || bridge->GetCvarBool(sv_logecho))
{
static char conBuffer[4096];
ke::SafeSprintf(conBuffer, sizeof(conBuffer), "L %s: %s\n", date, buffer);
smcore.ConPrint(conBuffer);
bridge->ConPrint(conBuffer);
}
}
@ -475,7 +475,7 @@ void Logger::_PrintToGameLog(const char *fmt, va_list ap)
msg[len++] = '\n';
msg[len] = '\0';
smcore.LogToGame(msg);
bridge->LogToGame(msg);
}
const char *Logger::GetLogFileName(LogType type) const

View File

@ -374,7 +374,7 @@ void CPlugin::Call_OnAllPluginsLoaded()
pFunction->Execute(&result);
}
if (smcore.IsMapRunning())
if (bridge->IsMapRunning())
{
if ((pFunction = m_pRuntime->GetFunctionByName("OnMapStart")) != NULL)
{
@ -382,9 +382,9 @@ void CPlugin::Call_OnAllPluginsLoaded()
}
}
if (smcore.AreConfigsExecuted())
if (bridge->AreConfigsExecuted())
{
smcore.ExecuteConfigs(GetBaseContext());
bridge->ExecuteConfigs(GetBaseContext());
}
}
@ -1801,7 +1801,7 @@ bool CPluginManager::TestAliasMatch(const char *alias, const char *localpath)
bool CPluginManager::IsLateLoadTime() const
{
return (m_AllPluginsLoaded || !smcore.IsMapLoading());
return (m_AllPluginsLoaded || !bridge->IsMapLoading());
}
void CPluginManager::OnSourceModAllInitialized()
@ -2275,7 +2275,7 @@ void CPluginManager::OnRootConsoleCommand(const char *cmdname, const ICommandArg
else if (strcmp(cmd, "refresh") == 0)
{
RefreshAll();
smcore.DoGlobalPluginLoads();
bridge->DoGlobalPluginLoads();
rootmenu->ConsolePrint("[SM] The plugin list has been refreshed and reloaded.");
return;
}

View File

@ -65,7 +65,7 @@ void RootConsoleMenu::ConsolePrint(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
smcore.ConsolePrintVa(fmt, ap);
bridge->ConsolePrintVa(fmt, ap);
va_end(ap);
}

View File

@ -737,7 +737,7 @@ void Translator::OnSourceModAllInitialized()
{
AddLanguage("en", "English");
const char* lang = smcore.GetCoreConfigValue("ServerLang");
const char* lang = bridge->GetCoreConfigValue("ServerLang");
if (lang)
{
strncpy(m_InitialLang, lang, sizeof(m_InitialLang));

View File

@ -55,30 +55,32 @@
#include "LibrarySys.h"
#include "RootConsoleMenu.h"
sm_core_t smcore;
IHandleSys *handlesys = &g_HandleSys;
IdentityToken_t *g_pCoreIdent;
SMGlobalClass *SMGlobalClass::head = NULL;
ISourceMod *g_pSM;
CoreProvider *bridge = nullptr;
ISourceMod *g_pSM = nullptr;
IVEngineServer *engine = nullptr;
IdentityToken_t *g_pCoreIdent = nullptr;
ITimerSystem *timersys = nullptr;
IGameHelpers *gamehelpers = nullptr;
IMenuManager *menus = nullptr;
IPlayerManager *playerhelpers = nullptr;
IHandleSys *handlesys = &g_HandleSys;
ILibrarySys *libsys = &g_LibSys;
ITextParsers *textparser = &g_TextParser;
IVEngineServer *engine;
IShareSys *sharesys = &g_ShareSys;
IRootConsole *rootmenu = &g_RootMenu;
IPluginManager *pluginsys = g_PluginSys.GetOldAPI();
IForwardManager *forwardsys = &g_Forwards;
ITimerSystem *timersys;
ServerGlobals serverGlobals;
IPlayerManager *playerhelpers;
IAdminSystem *adminsys = &g_Admins;
IGameHelpers *gamehelpers;
ISourcePawnEngine *g_pSourcePawn;
ISourcePawnEngine2 *g_pSourcePawn2;
CNativeOwner g_CoreNatives;
IScriptManager *scripts = &g_PluginSys;
IExtensionSys *extsys = &g_Extensions;
ILogger *logger = &g_Logger;
IMenuManager *menus;
CNativeOwner g_CoreNatives;
static void AddCorePhraseFile(const char *filename)
{
@ -159,11 +161,11 @@ static sm_logic_t logic =
-1.0f
};
static void logic_init(const sm_core_t* core, sm_logic_t* _logic)
static void logic_init(CoreProvider* core, sm_logic_t* _logic)
{
logic.head = SMGlobalClass::head;
memcpy(&smcore, core, sizeof(sm_core_t));
bridge = core;
memcpy(_logic, &logic, sizeof(sm_logic_t));
memcpy(&serverGlobals, core->serverGlobals, sizeof(ServerGlobals));

View File

@ -37,7 +37,7 @@
#include "../sm_globals.h"
#include "intercom.h"
extern sm_core_t smcore;
extern CoreProvider *bridge;
extern IHandleSys *handlesys;
extern ISourceMod *g_pSM;
extern ILibrarySys *libsys;

View File

@ -52,7 +52,7 @@ using namespace SourceHook;
* Add 1 to the RHS of this expression to bump the intercom file
* This is to prevent mismatching core/logic binaries
*/
#define SM_LOGIC_MAGIC (0x0F47C0DE - 39)
#define SM_LOGIC_MAGIC (0x0F47C0DE - 40)
#if defined SM_LOGIC
class IVEngineServer
@ -275,8 +275,9 @@ private:
const CVector<IExtension *> *list_;
};
struct sm_core_t
class CoreProvider
{
public:
/* Objects */
ISourceMod *sm;
IVEngineServer *engine;
@ -357,7 +358,7 @@ struct sm_logic_t
float sentinel;
};
typedef void (*LogicInitFunction)(const sm_core_t *core, sm_logic_t *logic);
typedef void (*LogicInitFunction)(CoreProvider *core, sm_logic_t *logic);
typedef LogicInitFunction (*LogicLoadFunction)(uint32_t magic);
typedef ITextParsers *(*GetITextParsers)();

View File

@ -271,7 +271,7 @@ static cell_t BanClient(IPluginContext *pContext, const cell_t *params)
ban_source = params[7];
/* Check how we should ban the player */
if (!strcmp(smcore.GetSourceEngineName(), "darkmessiah"))
if (!strcmp(bridge->GetSourceEngineName(), "darkmessiah"))
{
/* Dark Messiah doesn't have Steam IDs so there is only one ban method to choose */
ban_flags |= BANFLAG_IP;

View File

@ -52,7 +52,7 @@ static cell_t CheckCommandAccess(IPluginContext *pContext, const cell_t *params)
bool found_command = false;
if (params[0] < 4 || !params[4])
{
found_command = smcore.LookForCommandAdminFlags(cmd, &bits);
found_command = bridge->LookForCommandAdminFlags(cmd, &bits);
}
if (!found_command)
@ -73,7 +73,7 @@ static cell_t CheckAccess(IPluginContext *pContext, const cell_t *params)
bool found_command = false;
if (params[0] < 4 || !params[4])
{
found_command = smcore.LookForCommandAdminFlags(cmd, &bits);
found_command = bridge->LookForCommandAdminFlags(cmd, &bits);
}
if (!found_command)
@ -96,7 +96,7 @@ static cell_t sm_PrintToServer(IPluginContext *pCtx, const cell_t *params)
buffer[res++] = '\n';
buffer[res] = '\0';
smcore.ConPrint(buffer);
bridge->ConPrint(buffer);
return 1;
}
@ -140,7 +140,7 @@ static cell_t sm_PrintToConsole(IPluginContext *pCtx, const cell_t *params)
pPlayer->PrintToConsole(buffer);
}
else {
smcore.ConPrint(buffer);
bridge->ConPrint(buffer);
}
return 1;
@ -277,7 +277,7 @@ static cell_t ReplyToCommand(IPluginContext *pContext, const cell_t *params)
/* Print */
buffer[len++] = '\n';
buffer[len] = '\0';
smcore.ConPrint(buffer);
bridge->ConPrint(buffer);
return 1;
}

View File

@ -78,7 +78,7 @@ public:
Param_Cell,
Param_String);
sm_datetime_format = smcore.FindConVar("sm_datetime_format");
sm_datetime_format = bridge->FindConVar("sm_datetime_format");
}
void OnHandleDestroy(HandleType_t type, void *object)
{
@ -173,7 +173,7 @@ static cell_t FormatTime(IPluginContext *pContext, const cell_t *params)
if (format == NULL)
{
format = const_cast<char *>(smcore.GetCvarString(sm_datetime_format));
format = const_cast<char *>(bridge->GetCvarString(sm_datetime_format));
}
#if defined SUBPLATFORM_SECURECRT

View File

@ -1405,7 +1405,7 @@ static cell_t SQL_ConnectCustom(IPluginContext *pContext, const cell_t *params)
err);
}
DatabaseInfo info = smcore.GetDBInfoFromKeyValues(kv);
DatabaseInfo info = bridge->GetDBInfoFromKeyValues(kv);
IDBDriver *driver;
if (info.driver[0] == '\0' || strcmp(info.driver, "default") == 0)

View File

@ -99,54 +99,54 @@ public:
}
static ValveFile *Open(const char *filename, const char *mode, const char *pathID) {
FileHandle_t handle = smcore.filesystem->Open(filename, mode, pathID);
FileHandle_t handle = bridge->filesystem->Open(filename, mode, pathID);
if (!handle)
return NULL;
return new ValveFile(handle);
}
static bool Delete(const char *filename, const char *pathID) {
if (!smcore.filesystem->FileExists(filename, pathID))
if (!bridge->filesystem->FileExists(filename, pathID))
return false;
smcore.filesystem->RemoveFile(filename, pathID);
bridge->filesystem->RemoveFile(filename, pathID);
if (smcore.filesystem->FileExists(filename, pathID))
if (bridge->filesystem->FileExists(filename, pathID))
return false;
return true;
}
size_t Read(void *pOut, int size) override {
return (size_t)smcore.filesystem->Read(pOut, size, handle_);
return (size_t)bridge->filesystem->Read(pOut, size, handle_);
}
char *ReadLine(char *pOut, int size) override {
return smcore.filesystem->ReadLine(pOut, size, handle_);
return bridge->filesystem->ReadLine(pOut, size, handle_);
}
size_t Write(const void *pData, int size) override {
return (size_t)smcore.filesystem->Write(pData, size, handle_);
return (size_t)bridge->filesystem->Write(pData, size, handle_);
}
bool Seek(int pos, int seek_type) override {
smcore.filesystem->Seek(handle_, pos, seek_type);
bridge->filesystem->Seek(handle_, pos, seek_type);
return !HasError();
}
int Tell() override {
return smcore.filesystem->Tell(handle_);
return bridge->filesystem->Tell(handle_);
}
bool HasError() override {
return !handle_ || !smcore.filesystem->IsOk(handle_);
return !handle_ || !bridge->filesystem->IsOk(handle_);
}
bool Flush() override {
smcore.filesystem->Flush(handle_);
bridge->filesystem->Flush(handle_);
return true;
}
bool EndOfFile() override {
return smcore.filesystem->EndOfFile(handle_);
return bridge->filesystem->EndOfFile(handle_);
}
void Close() override {
if (!handle_)
return;
smcore.filesystem->Close(handle_);
bridge->filesystem->Close(handle_);
handle_ = NULL;
}
virtual ValveFile *AsValveFile() {
@ -272,7 +272,7 @@ public:
else if (type == g_ValveDirType)
{
ValveDirectory *valveDir = (ValveDirectory *)object;
smcore.filesystem->FindClose(valveDir->hndl);
bridge->filesystem->FindClose(valveDir->hndl);
delete valveDir;
}
}
@ -330,7 +330,7 @@ static cell_t sm_OpenDirectory(IPluginContext *pContext, const cell_t *params)
ValveDirectory *valveDir = new ValveDirectory;
const char *pFirst = smcore.filesystem->FindFirstEx(wildcardedPath, pathID, &valveDir->hndl);
const char *pFirst = bridge->filesystem->FindFirstEx(wildcardedPath, pathID, &valveDir->hndl);
if (!pFirst)
{
delete valveDir;
@ -419,7 +419,7 @@ static cell_t sm_ReadDirEntry(IPluginContext *pContext, const cell_t *params)
}
else
{
pEntry = smcore.filesystem->FindNext(valveDir->hndl);
pEntry = bridge->filesystem->FindNext(valveDir->hndl);
}
valveDir->bHandledFirstPath = true;
@ -443,7 +443,7 @@ static cell_t sm_ReadDirEntry(IPluginContext *pContext, const cell_t *params)
return 0;
}
if (smcore.filesystem->FindIsDirectory(valveDir->hndl))
if (bridge->filesystem->FindIsDirectory(valveDir->hndl))
{
*filetype = 1;
} else {
@ -557,7 +557,7 @@ static cell_t sm_FileExists(IPluginContext *pContext, const cell_t *params)
if (params[0] >= 3)
pContext->LocalToStringNULL(params[3], &pathID);
return smcore.filesystem->FileExists(name, pathID) ? 1 : 0;
return bridge->filesystem->FileExists(name, pathID) ? 1 : 0;
}
char realpath[PLATFORM_MAX_PATH];
@ -598,7 +598,7 @@ static cell_t sm_RenameFile(IPluginContext *pContext, const cell_t *params)
char *pathID;
pContext->LocalToStringNULL(params[4], &pathID);
smcore.filesystem->RenameFile(oldpath, newpath, pathID);
bridge->filesystem->RenameFile(oldpath, newpath, pathID);
return 1;
}
@ -629,7 +629,7 @@ static cell_t sm_DirExists(IPluginContext *pContext, const cell_t *params)
char *pathID;
pContext->LocalToStringNULL(params[3], &pathID);
return smcore.filesystem->IsDirectory(name, pathID) ? 1 : 0;
return bridge->filesystem->IsDirectory(name, pathID) ? 1 : 0;
}
char realpath[PLATFORM_MAX_PATH];
@ -671,9 +671,9 @@ static cell_t sm_FileSize(IPluginContext *pContext, const cell_t *params)
if (params[0] >= 3)
pContext->LocalToStringNULL(params[3], &pathID);
if (!smcore.filesystem->FileExists(name, pathID))
if (!bridge->filesystem->FileExists(name, pathID))
return -1;
return smcore.filesystem->Size(name, pathID);
return bridge->filesystem->Size(name, pathID);
}
char realpath[PLATFORM_MAX_PATH];
@ -730,12 +730,12 @@ static cell_t sm_CreateDirectory(IPluginContext *pContext, const cell_t *params)
char *pathID;
pContext->LocalToStringNULL(params[4], &pathID);
if (smcore.filesystem->IsDirectory(name, pathID))
if (bridge->filesystem->IsDirectory(name, pathID))
return 0;
smcore.filesystem->CreateDirHierarchy(name, pathID);
bridge->filesystem->CreateDirHierarchy(name, pathID);
if (smcore.filesystem->IsDirectory(name, pathID))
if (bridge->filesystem->IsDirectory(name, pathID))
return 1;
return 0;
@ -783,8 +783,8 @@ static cell_t sm_WriteFileLine(IPluginContext *pContext, const cell_t *params)
if (SystemFile *sysfile = file->AsSystemFile()) {
fprintf(sysfile->fp(), "%s\n", buffer);
} else if (ValveFile *vfile = file->AsValveFile()) {
smcore.filesystem->FPrint(vfile->handle(), buffer);
smcore.filesystem->FPrint(vfile->handle(), "\n");
bridge->filesystem->FPrint(vfile->handle(), buffer);
bridge->filesystem->FPrint(vfile->handle(), "\n");
} else {
assert(false);
}
@ -840,7 +840,7 @@ static cell_t sm_LogToGame(IPluginContext *pContext, const cell_t *params)
buffer[len] = '\0';
}
smcore.LogToGame(buffer);
bridge->LogToGame(buffer);
return 1;
}

View File

@ -87,13 +87,13 @@ public:
}
void GetMapCycleFilePath(char *pBuffer, int maxlen)
{
const char *pMapCycleFileName = m_pMapCycleFile ? smcore.GetCvarString(m_pMapCycleFile) : "mapcycle.txt";
const char *pMapCycleFileName = m_pMapCycleFile ? bridge->GetCvarString(m_pMapCycleFile) : "mapcycle.txt";
g_pSM->Format(pBuffer, maxlen, "cfg/%s", pMapCycleFileName);
if (!smcore.filesystem->FileExists(pBuffer, "GAME"))
if (!bridge->filesystem->FileExists(pBuffer, "GAME"))
{
g_pSM->Format(pBuffer, maxlen, "%s", pMapCycleFileName);
if (!smcore.filesystem->FileExists(pBuffer, "GAME"))
if (!bridge->filesystem->FileExists(pBuffer, "GAME"))
{
g_pSM->Format(pBuffer, maxlen, "cfg/mapcycle_default.txt");
}
@ -158,7 +158,7 @@ public:
return;
}
m_pMapCycleFile = smcore.FindConVar("mapcyclefile");
m_pMapCycleFile = bridge->FindConVar("mapcyclefile");
/* Dump everything we know about. */
List<maplist_info_t *> compat;
@ -363,7 +363,7 @@ public:
cell_t *blk;
FileFindHandle_t findHandle;
const char *fileName = smcore.filesystem->FindFirstEx("maps/*.bsp", "GAME", &findHandle);
const char *fileName = bridge->filesystem->FindFirstEx("maps/*.bsp", "GAME", &findHandle);
while (fileName)
{
@ -373,22 +373,22 @@ public:
if (!gamehelpers->IsMapValid(buffer))
{
fileName = smcore.filesystem->FindNext(findHandle);
fileName = bridge->filesystem->FindNext(findHandle);
continue;
}
if ((blk = pNewArray->push()) == NULL)
{
fileName = smcore.filesystem->FindNext(findHandle);
fileName = bridge->filesystem->FindNext(findHandle);
continue;
}
strncopy((char *)blk, buffer, 255);
fileName = smcore.filesystem->FindNext(findHandle);
fileName = bridge->filesystem->FindNext(findHandle);
}
smcore.filesystem->FindClose(findHandle);
bridge->filesystem->FindClose(findHandle);
/* Remove the array if there were no items. */
if (pNewArray->size() == 0)
@ -493,7 +493,7 @@ private:
cell_t *blk;
char buffer[255];
if ((fp = smcore.filesystem->Open(pMapList->path, "rt", "GAME")) == NULL)
if ((fp = bridge->filesystem->Open(pMapList->path, "rt", "GAME")) == NULL)
{
return false;
}
@ -501,7 +501,7 @@ private:
delete pMapList->pArray;
pMapList->pArray = new CellArray(64);
while (!smcore.filesystem->EndOfFile(fp) && smcore.filesystem->ReadLine(buffer, sizeof(buffer), fp) != NULL)
while (!bridge->filesystem->EndOfFile(fp) && bridge->filesystem->ReadLine(buffer, sizeof(buffer), fp) != NULL)
{
size_t len = strlen(buffer);
char *ptr = UTIL_TrimWhitespace(buffer, len);
@ -512,7 +512,7 @@ private:
continue;
}
if (strcmp(smcore.GetSourceEngineName(), "insurgency") == 0)
if (strcmp(bridge->GetSourceEngineName(), "insurgency") == 0)
{
// Insurgency (presumably?) doesn't allow spaces in map names
// and does use a space to delimit the map name from the map mode
@ -539,7 +539,7 @@ private:
}
}
smcore.filesystem->Close(fp);
bridge->filesystem->Close(fp);
pMapList->last_modified_time = last_time;
pMapList->serial = ++m_nSerialChange;

View File

@ -281,13 +281,13 @@ static cell_t sm_GetClientName(IPluginContext *pCtx, const cell_t *params)
static ConVar *hostname = NULL;
if (!hostname)
{
hostname = smcore.FindConVar("hostname");
hostname = bridge->FindConVar("hostname");
if (!hostname)
{
return pCtx->ThrowNativeError("Could not find \"hostname\" cvar");
}
}
pCtx->StringToLocalUTF8(params[2], static_cast<size_t>(params[3]), smcore.GetCvarString(hostname), NULL);
pCtx->StringToLocalUTF8(params[2], static_cast<size_t>(params[3]), bridge->GetCvarString(hostname), NULL);
return 1;
}
@ -763,7 +763,7 @@ static cell_t IsClientObserver(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("IPlayerInfo not supported by game");
}
return smcore.playerInfo->IsObserver(pInfo) ? 1 : 0;
return bridge->playerInfo->IsObserver(pInfo) ? 1 : 0;
}
static cell_t GetClientTeam(IPluginContext *pContext, const cell_t *params)
@ -785,7 +785,7 @@ static cell_t GetClientTeam(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("IPlayerInfo not supported by game");
}
return smcore.playerInfo->GetTeamIndex(pInfo);
return bridge->playerInfo->GetTeamIndex(pInfo);
}
static cell_t GetFragCount(IPluginContext *pContext, const cell_t *params)
@ -807,7 +807,7 @@ static cell_t GetFragCount(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("IPlayerInfo not supported by game");
}
return smcore.playerInfo->GetFragCount(pInfo);
return bridge->playerInfo->GetFragCount(pInfo);
}
static cell_t GetDeathCount(IPluginContext *pContext, const cell_t *params)
@ -829,7 +829,7 @@ static cell_t GetDeathCount(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("IPlayerInfo not supported by game");
}
return smcore.playerInfo->GetDeathCount(pInfo);
return bridge->playerInfo->GetDeathCount(pInfo);
}
static cell_t GetArmorValue(IPluginContext *pContext, const cell_t *params)
@ -851,7 +851,7 @@ static cell_t GetArmorValue(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("IPlayerInfo not supported by game");
}
return smcore.playerInfo->GetArmorValue(pInfo);
return bridge->playerInfo->GetArmorValue(pInfo);
}
static cell_t GetAbsOrigin(IPluginContext *pContext, const cell_t *params)
@ -877,7 +877,7 @@ static cell_t GetAbsOrigin(IPluginContext *pContext, const cell_t *params)
pContext->LocalToPhysAddr(params[2], &pVec);
float x, y, z;
smcore.playerInfo->GetAbsOrigin(pInfo, &x, &y, &z);
bridge->playerInfo->GetAbsOrigin(pInfo, &x, &y, &z);
pVec[0] = sp_ftoc(x);
pVec[1] = sp_ftoc(y);
pVec[2] = sp_ftoc(z);
@ -908,7 +908,7 @@ static cell_t GetAbsAngles(IPluginContext *pContext, const cell_t *params)
pContext->LocalToPhysAddr(params[2], &pAng);
float x, y, z;
smcore.playerInfo->GetAbsAngles(pInfo, &x, &y, &z);
bridge->playerInfo->GetAbsAngles(pInfo, &x, &y, &z);
pAng[0] = sp_ftoc(x);
pAng[1] = sp_ftoc(y);
pAng[2] = sp_ftoc(z);
@ -939,7 +939,7 @@ static cell_t GetPlayerMins(IPluginContext *pContext, const cell_t *params)
pContext->LocalToPhysAddr(params[2], &pVec);
float x, y, z;
smcore.playerInfo->GetPlayerMins(pInfo, &x, &y, &z);
bridge->playerInfo->GetPlayerMins(pInfo, &x, &y, &z);
pVec[0] = sp_ftoc(x);
pVec[1] = sp_ftoc(y);
pVec[2] = sp_ftoc(z);
@ -970,7 +970,7 @@ static cell_t GetPlayerMaxs(IPluginContext *pContext, const cell_t *params)
pContext->LocalToPhysAddr(params[2], &pVec);
float x, y, z;
smcore.playerInfo->GetPlayerMaxs(pInfo, &x, &y, &z);
bridge->playerInfo->GetPlayerMaxs(pInfo, &x, &y, &z);
pVec[0] = sp_ftoc(x);
pVec[1] = sp_ftoc(y);
pVec[2] = sp_ftoc(z);
@ -997,7 +997,7 @@ static cell_t GetWeaponName(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("IPlayerInfo not supported by game");
}
const char *weapon = smcore.playerInfo->GetWeaponName(pInfo);
const char *weapon = bridge->playerInfo->GetWeaponName(pInfo);
pContext->StringToLocalUTF8(params[2], static_cast<size_t>(params[3]), weapon ? weapon : "", NULL);
return 1;
@ -1022,7 +1022,7 @@ static cell_t GetModelName(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("IPlayerInfo not supported by game");
}
const char *model = smcore.playerInfo->GetModelName(pInfo);
const char *model = bridge->playerInfo->GetModelName(pInfo);
pContext->StringToLocalUTF8(params[2], static_cast<size_t>(params[3]), model ? model : "", NULL);
return 1;
@ -1047,7 +1047,7 @@ static cell_t GetHealth(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("IPlayerInfo not supported by game");
}
return smcore.playerInfo->GetHealth(pInfo);
return bridge->playerInfo->GetHealth(pInfo);
}
static cell_t GetClientOfUserId(IPluginContext *pContext, const cell_t *params)
@ -1062,7 +1062,7 @@ static cell_t _ShowActivity(IPluginContext *pContext,
{
char message[255];
char buffer[255];
int value = smcore.GetActivityFlags();
int value = bridge->GetActivityFlags();
unsigned int replyto = playerhelpers->GetReplyTo();
int client = params[1];
@ -1113,7 +1113,7 @@ static cell_t _ShowActivity(IPluginContext *pContext,
}
g_pSM->Format(message, sizeof(message), "%s%s\n", tag, buffer);
smcore.ConPrint(message);
bridge->ConPrint(message);
}
if (value == kActivityNone)
@ -1193,7 +1193,7 @@ static cell_t _ShowActivity2(IPluginContext *pContext,
{
char message[255];
char buffer[255];
int value = smcore.GetActivityFlags();
int value = bridge->GetActivityFlags();
unsigned int replyto = playerhelpers->GetReplyTo();
int client = params[1];
@ -1240,7 +1240,7 @@ static cell_t _ShowActivity2(IPluginContext *pContext,
}
g_pSM->Format(message, sizeof(message), "%s%s\n", tag, buffer);
smcore.ConPrint(message);
bridge->ConPrint(message);
}
if (value == kActivityNone)
@ -1426,7 +1426,7 @@ static cell_t ChangeClientTeam(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("IPlayerInfo not supported by game");
}
smcore.playerInfo->ChangeTeam(pInfo, params[2]);
bridge->playerInfo->ChangeTeam(pInfo, params[2]);
return 1;
}
@ -1528,7 +1528,7 @@ static cell_t FormatActivitySource(IPluginContext *pContext, const cell_t *param
return pContext->ThrowNativeError("Client %d not connected", target);
}
value = smcore.GetActivityFlags();
value = bridge->GetActivityFlags();
if (client != 0)
{

View File

@ -78,7 +78,7 @@ try_serverlang:
{
langid = g_Translator.GetServerLanguage();
}
else if ((target >= 1) && (target <= smcore.MaxClients()))
else if ((target >= 1) && (target <= bridge->MaxClients()))
{
langid = g_Translator.GetClientLanguage(target);
}
@ -794,7 +794,7 @@ try_again:
{
lang_id = g_Translator.GetServerLanguage();
}
else if (target >= 1 && target <= smcore.MaxClients())
else if (target >= 1 && target <= bridge->MaxClients())
{
lang_id = g_Translator.GetClientLanguage(target);
}
@ -1123,7 +1123,7 @@ reswitch:
const char *name;
const char *auth;
int userid;
if (!smcore.DescribePlayer(*value, &name, &auth, &userid))
if (!bridge->DescribePlayer(*value, &name, &auth, &userid))
return pCtx->ThrowNativeError("Client index %d is invalid", *value);
ke::SafeSprintf(buffer,
sizeof(buffer),
@ -1150,7 +1150,7 @@ reswitch:
const char *name = "Console";
if (*value) {
if (!smcore.DescribePlayer(*value, &name, nullptr, nullptr))
if (!bridge->DescribePlayer(*value, &name, nullptr, nullptr))
return pCtx->ThrowNativeError("Client index %d is invalid", *value);
}
AddString(&buf_p, llen, name, width, prec);
@ -1190,7 +1190,7 @@ reswitch:
char *key;
bool error;
size_t res;
cell_t target = smcore.GetGlobalTarget();
cell_t target = bridge->GetGlobalTarget();
pCtx->LocalToString(params[arg++], &key);
res = Translate(buf_p, llen, pCtx, key, target, params, &arg, &error);
if (error)

View File

@ -608,7 +608,7 @@ void UTIL_ConsolePrint(const char *fmt, ...)
static ServerGlobals serverGlobals;
static sm_core_t core_bridge =
static CoreProvider core_bridge =
{
/* Objects */
&g_SourceMod,