Tweaked Dota 2 support to account for lack of IPluginHelpers (bug 5656, r=asherkin).

This commit is contained in:
Nicholas Hastings 2013-03-19 11:19:19 -04:00
parent 519e8c5fcd
commit 877ef76540
9 changed files with 30 additions and 0 deletions

View File

@ -283,7 +283,11 @@ void ChatTriggers::OnSayCommand_Post()
/* Execute the cached command */
int client = g_ConCmds.GetCommandClient();
unsigned int old = SetReplyTo(SM_REPLY_CHAT);
#if SOURCE_ENGINE == SE_DOTA
engine->ClientCommand(PEntityOfEntIndex(client), "%s", m_ToExecute);
#else
serverpluginhelpers->ClientCommand(PEntityOfEntIndex(client), m_ToExecute);
#endif
SetReplyTo(old);
}
}

View File

@ -614,10 +614,12 @@ QueryCvarCookie_t ConVarManager::QueryClientConVar(edict_t *pPlayer, const char
{
cookie = engine->StartQueryCvarValue(pPlayer, name);
}
#if SOURCE_ENGINE != SE_DOTA
else if (m_bIsVSPQueryHooked)
{
cookie = serverpluginhelpers->StartQueryCvarValue(pPlayer, name);
}
#endif
else
{
return InvalidQueryCvarCookie;

View File

@ -733,7 +733,11 @@ void CHalfLife2::ProcessFakeCliCmdQueue()
if (g_Players.GetClientOfUserId(pFake->userid) == pFake->client)
{
CPlayer *pPlayer = g_Players.GetPlayerByIndex(pFake->client);
#if SOURCE_ENGINE == SE_DOTA
engine->ClientCommand(pPlayer->GetEdict(), "%s", pFake->cmd.c_str());
#else
serverpluginhelpers->ClientCommand(pPlayer->GetEdict(), pFake->cmd.c_str());
#endif
}
m_CmdQueue.pop();

View File

@ -65,16 +65,20 @@ bool ValveMenuStyle::OnClientCommand(int client, const char *cmdname, const CCom
void ValveMenuStyle::OnSourceModAllInitialized()
{
#if SOURCE_ENGINE != SE_DOTA
g_Players.AddClientListener(this);
SH_ADD_HOOK(IServerPluginHelpers, CreateMessage, serverpluginhelpers, SH_MEMBER(this, &ValveMenuStyle::HookCreateMessage), false);
g_pSPHCC = SH_GET_CALLCLASS(serverpluginhelpers);
#endif
}
void ValveMenuStyle::OnSourceModShutdown()
{
#if SOURCE_ENGINE != SE_DOTA
SH_RELEASE_CALLCLASS(g_pSPHCC);
SH_REMOVE_HOOK(IServerPluginHelpers, CreateMessage, serverpluginhelpers, SH_MEMBER(this, &ValveMenuStyle::HookCreateMessage), false);
g_Players.RemoveClientListener(this);
#endif
}
void ValveMenuStyle::HookCreateMessage(edict_t *pEdict,

View File

@ -1105,7 +1105,11 @@ static cell_t FakeClientCommand(IPluginContext *pContext, const cell_t *params)
return 0;
}
#if SOURCE_ENGINE == SE_DOTA
engine->ClientCommand(pPlayer->GetEdict(), "%s", buffer);
#else
serverpluginhelpers->ClientCommand(pPlayer->GetEdict(), buffer);
#endif
return 1;
}

View File

@ -254,6 +254,9 @@ static cell_t IsSoundPrecached(IPluginContext *pContext, const cell_t *params)
static cell_t smn_CreateDialog(IPluginContext *pContext, const cell_t *params)
{
#if SOURCE_ENGINE == SE_DOTA
return pContext->ThrowNativeError("CreateDialog is not supported on this game");
#else
KeyValues *pKV;
HandleError herr;
Handle_t hndl = static_cast<Handle_t>(params[2]);
@ -281,6 +284,7 @@ static cell_t smn_CreateDialog(IPluginContext *pContext, const cell_t *params)
vsp_interface);
return 1;
#endif // DOTA
}
static cell_t PrintToChat(IPluginContext *pContext, const cell_t *params)

View File

@ -69,7 +69,9 @@ bool SourceMod_Core::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen
GET_V_IFACE_CURRENT(GetEngineFactory, engrandom, IUniformRandomStream, VENGINE_SERVER_RANDOM_INTERFACE_VERSION);
GET_V_IFACE_CURRENT(GetFileSystemFactory, basefilesystem, IBaseFileSystem, BASEFILESYSTEM_INTERFACE_VERSION);
GET_V_IFACE_CURRENT(GetEngineFactory, enginesound, IEngineSound, IENGINESOUND_SERVER_INTERFACE_VERSION);
#if SOURCE_ENGINE != SE_DOTA
GET_V_IFACE_CURRENT(GetEngineFactory, serverpluginhelpers, IServerPluginHelpers, INTERFACEVERSION_ISERVERPLUGINHELPERS);
#endif
/* :TODO: Make this optional and... make it find earlier versions [?] */
GET_V_IFACE_CURRENT(GetServerFactory, playerinfo, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER);

View File

@ -247,7 +247,9 @@ bool SDKTools::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool
GET_V_IFACE_ANY(GetEngineFactory, engsound, IEngineSound, IENGINESOUND_SERVER_INTERFACE_VERSION);
GET_V_IFACE_ANY(GetEngineFactory, enginetrace, IEngineTrace, INTERFACEVERSION_ENGINETRACE_SERVER);
GET_V_IFACE_ANY(GetEngineFactory, netstringtables, INetworkStringTableContainer, INTERFACENAME_NETWORKSTRINGTABLESERVER);
#if SOURCE_ENGINE != SE_DOTA
GET_V_IFACE_ANY(GetEngineFactory, pluginhelpers, IServerPluginHelpers, INTERFACEVERSION_ISERVERPLUGINHELPERS);
#endif
GET_V_IFACE_ANY(GetServerFactory, serverClients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS);
GET_V_IFACE_ANY(GetEngineFactory, voiceserver, IVoiceServer, INTERFACEVERSION_VOICESERVER);
GET_V_IFACE_ANY(GetServerFactory, playerinfomngr, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER);

View File

@ -565,7 +565,11 @@ static cell_t SlapPlayer(IPluginContext *pContext, const cell_t *params)
/* Force suicide */
if (should_slay)
{
#if SOURCE_ENGINE == SE_DOTA
engine->ClientCommand(pEdict, "kill\n");
#else
pluginhelpers->ClientCommand(pEdict, "kill\n");
#endif
}
if (s_frag_offs > 0)