From c230cf5aab39182c67ab3d14e99f5e206ebfb02c Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Fri, 12 Jul 2013 02:31:41 -0400 Subject: [PATCH] Updated for latest hl2sdk-dota changes. --- core/CellRecipientFilter.h | 6 +- core/ChatTriggers.cpp | 6 +- core/ChatTriggers.h | 4 +- core/ConCmdManager.cpp | 4 +- core/ConCmdManager.h | 2 +- core/ConVarManager.cpp | 19 ++++++- core/ConVarManager.h | 5 +- core/ConsoleDetours.cpp | 4 +- core/CoreConfig.cpp | 6 +- core/NextMap.cpp | 4 +- core/NextMap.h | 4 +- core/PlayerManager.cpp | 37 +++++++----- core/PlayerManager.h | 18 +++--- core/convar_sm_dota.h | 68 ++++++++++++++--------- core/smn_halflife.cpp | 3 +- core/smn_usermsgs.cpp | 2 +- extensions/sdktools/CellRecipientFilter.h | 6 +- extensions/sdktools/extension.h | 2 +- extensions/sdktools/tenatives.cpp | 2 +- extensions/sdktools/voice.cpp | 5 +- extensions/sdktools/vsound.cpp | 19 ++++++- extensions/sdktools/vsound.h | 10 +++- 22 files changed, 148 insertions(+), 88 deletions(-) diff --git a/core/CellRecipientFilter.h b/core/CellRecipientFilter.h index 87ccd1d1..4807df5a 100644 --- a/core/CellRecipientFilter.h +++ b/core/CellRecipientFilter.h @@ -45,7 +45,7 @@ public: //IRecipientFilter bool IsInitMessage() const; int GetRecipientCount() const; #if SOURCE_ENGINE == SE_DOTA - void GetRecipientIndex(int *clientIndex, int slot) const; + CEntityIndex GetRecipientIndex(int slot) const; #else int GetRecipientIndex(int slot) const; #endif @@ -84,7 +84,7 @@ inline int CellRecipientFilter::GetRecipientCount() const } #if SOURCE_ENGINE == SE_DOTA -inline void CellRecipientFilter::GetRecipientIndex(int *clientIndex, int slot) const +inline CEntityIndex CellRecipientFilter::GetRecipientIndex(int slot) const #else inline int CellRecipientFilter::GetRecipientIndex(int slot) const #endif @@ -97,7 +97,7 @@ inline int CellRecipientFilter::GetRecipientIndex(int slot) const ret = static_cast(m_Players[slot]); #if SOURCE_ENGINE == SE_DOTA - *clientIndex = ret; + return CEntityIndex(ret); #else return ret; #endif diff --git a/core/ChatTriggers.cpp b/core/ChatTriggers.cpp index 9787b8ad..b2e14e1e 100644 --- a/core/ChatTriggers.cpp +++ b/core/ChatTriggers.cpp @@ -38,7 +38,7 @@ #include "logic_bridge.h" #if SOURCE_ENGINE == SE_DOTA -SH_DECL_EXTERN2_void(ConCommand, Dispatch, SH_NOATTRIB, false, void *, const CCommand &); +SH_DECL_EXTERN2_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommandContext &, const CCommand &); #elif SOURCE_ENGINE >= SE_ORANGEBOX SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &); #elif SOURCE_ENGINE == SE_DARKMESSIAH @@ -148,7 +148,7 @@ void ChatTriggers::OnSourceModShutdown() } #if SOURCE_ENGINE == SE_DOTA -void ChatTriggers::OnSayCommand_Pre(void *pUnknown, const CCommand &command) +void ChatTriggers::OnSayCommand_Pre(const CCommandContext &context, const CCommand &command) { #elif SOURCE_ENGINE >= SE_ORANGEBOX void ChatTriggers::OnSayCommand_Pre(const CCommand &command) @@ -268,7 +268,7 @@ void ChatTriggers::OnSayCommand_Pre() } #if SOURCE_ENGINE == SE_DOTA -void ChatTriggers::OnSayCommand_Post(void *pUnknown, const CCommand &command) +void ChatTriggers::OnSayCommand_Post(const CCommandContext &context, const CCommand &command) #elif SOURCE_ENGINE >= SE_ORANGEBOX void ChatTriggers::OnSayCommand_Post(const CCommand &command) #else diff --git a/core/ChatTriggers.h b/core/ChatTriggers.h index 2f0eda9f..6b8f98a7 100644 --- a/core/ChatTriggers.h +++ b/core/ChatTriggers.h @@ -55,8 +55,8 @@ public: //SMGlobalClass size_t maxlength); private: //ConCommand #if SOURCE_ENGINE == SE_DOTA - void OnSayCommand_Pre(void *pUnknown, const CCommand &command); - void OnSayCommand_Post(void *pUnknown, const CCommand &command); + void OnSayCommand_Pre(const CCommandContext &, const CCommand &command); + void OnSayCommand_Post(const CCommandContext &, const CCommand &command); #elif SOURCE_ENGINE >= SE_ORANGEBOX void OnSayCommand_Pre(const CCommand &command); void OnSayCommand_Post(const CCommand &command); diff --git a/core/ConCmdManager.cpp b/core/ConCmdManager.cpp index d4788230..971fe139 100644 --- a/core/ConCmdManager.cpp +++ b/core/ConCmdManager.cpp @@ -41,7 +41,7 @@ ConCmdManager g_ConCmds; #if SOURCE_ENGINE == SE_DOTA - SH_DECL_HOOK2_void(ConCommand, Dispatch, SH_NOATTRIB, false, void *, const CCommand &); + SH_DECL_HOOK2_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommandContext &, const CCommand &); #elif SOURCE_ENGINE >= SE_ORANGEBOX SH_DECL_HOOK1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &); #else @@ -209,7 +209,7 @@ void ConCmdManager::OnPluginDestroyed(IPlugin *plugin) } } #if SOURCE_ENGINE == SE_DOTA -void CommandCallback(void *pUnknown, const CCommand &command) +void CommandCallback(const CCommandContext &context, const CCommand &command) { #elif SOURCE_ENGINE >= SE_ORANGEBOX void CommandCallback(const CCommand &command) diff --git a/core/ConCmdManager.h b/core/ConCmdManager.h index 05c1d32e..fa8826f7 100644 --- a/core/ConCmdManager.h +++ b/core/ConCmdManager.h @@ -99,7 +99,7 @@ class ConCmdManager : public IConCommandTracker { #if SOURCE_ENGINE == SE_DOTA - friend void CommandCallback(void *pUnknown, const CCommand &command); + friend void CommandCallback(const CCommandContext &context, const CCommand &command); #elif SOURCE_ENGINE >= SE_ORANGEBOX friend void CommandCallback(const CCommand &command); #else diff --git a/core/ConVarManager.cpp b/core/ConVarManager.cpp index ca76d6cc..01a1a1f6 100644 --- a/core/ConVarManager.cpp +++ b/core/ConVarManager.cpp @@ -44,7 +44,10 @@ SH_DECL_HOOK3_void(ICvar, CallGlobalChangeCallbacks, SH_NOATTRIB, false, ConVar SH_DECL_HOOK2_void(ICvar, CallGlobalChangeCallback, SH_NOATTRIB, false, ConVar *, const char *); #endif -#if SOURCE_ENGINE != SE_DARKMESSIAH +#if SOURCE_ENGINE == SE_DOTA +SH_DECL_HOOK5_void(IServerGameDLL, OnQueryCvarValueFinished, SH_NOATTRIB, 0, QueryCvarCookie_t, CEntityIndex, EQueryCvarValueStatus, const char *, const char *); +SH_DECL_HOOK5_void(IServerPluginCallbacks, OnQueryCvarValueFinished, SH_NOATTRIB, 0, QueryCvarCookie_t, CEntityIndex, EQueryCvarValueStatus, const char *, const char *); +#elif SOURCE_ENGINE != SE_DARKMESSIAH SH_DECL_HOOK5_void(IServerGameDLL, OnQueryCvarValueFinished, SH_NOATTRIB, 0, QueryCvarCookie_t, edict_t *, EQueryCvarValueStatus, const char *, const char *); SH_DECL_HOOK5_void(IServerPluginCallbacks, OnQueryCvarValueFinished, SH_NOATTRIB, 0, QueryCvarCookie_t, edict_t *, EQueryCvarValueStatus, const char *, const char *); #endif @@ -185,7 +188,9 @@ void ConVarManager::OnSourceModShutdown() } else if (m_bIsVSPQueryHooked) { +#if SOURCE_ENGINE != SE_DOTA SH_REMOVE_HOOK(IServerPluginCallbacks, OnQueryCvarValueFinished, vsp_interface, SH_MEMBER(this, &ConVarManager::OnQueryCvarValueFinished), false); +#endif m_bIsVSPQueryHooked = false; } #endif @@ -232,7 +237,7 @@ void ConVarManager::OnSourceModVSPReceived() } #endif -#if SOURCE_ENGINE != SE_DARKMESSIAH +#if SOURCE_ENGINE != SE_DARKMESSIAH && SOURCE_ENGINE != SE_DOTA SH_ADD_HOOK(IServerPluginCallbacks, OnQueryCvarValueFinished, vsp_interface, SH_MEMBER(this, &ConVarManager::OnQueryCvarValueFinished), false); m_bIsVSPQueryHooked = true; #endif @@ -612,7 +617,7 @@ QueryCvarCookie_t ConVarManager::QueryClientConVar(edict_t *pPlayer, const char if (m_bIsDLLQueryHooked) { #if SOURCE_ENGINE == SE_DOTA - cookie = engine->StartQueryCvarValue(IndexOfEdict(pPlayer), name); + cookie = engine->StartQueryCvarValue(CEntityIndex(IndexOfEdict(pPlayer)), name); #else cookie = engine->StartQueryCvarValue(pPlayer, name); #endif @@ -727,7 +732,11 @@ bool ConVarManager::IsQueryingSupported() } #if SOURCE_ENGINE != SE_DARKMESSIAH +#if SOURCE_ENGINE == SE_DOTA +void ConVarManager::OnQueryCvarValueFinished(QueryCvarCookie_t cookie, CEntityIndex player, EQueryCvarValueStatus result, const char *cvarName, const char *cvarValue) +#else void ConVarManager::OnQueryCvarValueFinished(QueryCvarCookie_t cookie, edict_t *pPlayer, EQueryCvarValueStatus result, const char *cvarName, const char *cvarValue) +#endif // SE_DOTA { IPluginFunction *pCallback = NULL; cell_t value = 0; @@ -749,7 +758,11 @@ void ConVarManager::OnQueryCvarValueFinished(QueryCvarCookie_t cookie, edict_t * cell_t ret; pCallback->PushCell(cookie); +#if SOURCE_ENGINE == SE_DOTA + pCallback->PushCell(player.Get()); +#else pCallback->PushCell(IndexOfEdict(pPlayer)); +#endif pCallback->PushCell(result); pCallback->PushString(cvarName); diff --git a/core/ConVarManager.h b/core/ConVarManager.h index 6c9ddc9a..9637dbb1 100644 --- a/core/ConVarManager.h +++ b/core/ConVarManager.h @@ -154,7 +154,10 @@ private: /** * Callback for when StartQueryCvarValue() has finished. */ -#if SOURCE_ENGINE != SE_DARKMESSIAH +#if SOURCE_ENGINE == SE_DOTA + void OnQueryCvarValueFinished(QueryCvarCookie_t cookie, CEntityIndex player, EQueryCvarValueStatus result, + const char *cvarName, const char *cvarValue); +#elif SOURCE_ENGINE != SE_DARKMESSIAH void OnQueryCvarValueFinished(QueryCvarCookie_t cookie, edict_t *pPlayer, EQueryCvarValueStatus result, const char *cvarName, const char *cvarValue); #endif diff --git a/core/ConsoleDetours.cpp b/core/ConsoleDetours.cpp index 3243ac3f..fea1e37d 100644 --- a/core/ConsoleDetours.cpp +++ b/core/ConsoleDetours.cpp @@ -60,7 +60,7 @@ #if SH_IMPL_VERSION >= 5 # if SOURCE_ENGINE == SE_DOTA - SH_DECL_EXTERN2_void(ConCommand, Dispatch, SH_NOATTRIB, false, void *, const CCommand &); + SH_DECL_EXTERN2_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommandContext &, const CCommand &); # elif SOURCE_ENGINE >= SE_ORANGEBOX SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &); # else @@ -134,7 +134,7 @@ class GenericCommandHooker : public IConCommandLinkListener } # if SOURCE_ENGINE == SE_DOTA - void Dispatch(void *pUnknown, const CCommand& args) + void Dispatch(const CCommandContext &context, const CCommand& args) # elif SOURCE_ENGINE >= SE_ORANGEBOX void Dispatch(const CCommand& args) # else diff --git a/core/CoreConfig.cpp b/core/CoreConfig.cpp index b2b34f02..e29b9ff6 100644 --- a/core/CoreConfig.cpp +++ b/core/CoreConfig.cpp @@ -62,8 +62,8 @@ ConVar *g_ServerCfgFile = NULL; void CheckAndFinalizeConfigs(); #if SOURCE_ENGINE == SE_DOTA -SH_DECL_EXTERN2_void(ConCommand, Dispatch, SH_NOATTRIB, false, void *, const CCommand &); -void Hook_ExecDispatchPre(void *pUnknown, const CCommand &cmd) +SH_DECL_EXTERN2_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommandContext &, const CCommand &); +void Hook_ExecDispatchPre(const CCommandContext &context, const CCommand &cmd) #elif SOURCE_ENGINE >= SE_ORANGEBOX SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &); void Hook_ExecDispatchPre(const CCommand &cmd) @@ -93,7 +93,7 @@ void Hook_ExecDispatchPre() } #if SOURCE_ENGINE == SE_DOTA -void Hook_ExecDispatchPost(void *pUnknown, const CCommand &cmd) +void Hook_ExecDispatchPost(const CCommandContext &context, const CCommand &cmd) #elif SOURCE_ENGINE >= SE_ORANGEBOX void Hook_ExecDispatchPost(const CCommand &cmd) #else diff --git a/core/NextMap.cpp b/core/NextMap.cpp index 58cccf4a..a95a4062 100644 --- a/core/NextMap.cpp +++ b/core/NextMap.cpp @@ -46,7 +46,7 @@ SH_DECL_HOOK4_void(IVEngineServer, ChangeLevel, SH_NOATTRIB, 0, const char *, co #endif #if SOURCE_ENGINE == SE_DOTA -SH_DECL_EXTERN2_void(ConCommand, Dispatch, SH_NOATTRIB, false, void *, const CCommand &); +SH_DECL_EXTERN2_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommandContext &, const CCommand &); #elif SOURCE_ENGINE >= SE_ORANGEBOX SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &); #elif SOURCE_ENGINE == SE_DARKMESSIAH @@ -208,7 +208,7 @@ NextMapManager::NextMapManager() } #if SOURCE_ENGINE == SE_DOTA -void CmdChangeLevelCallback(void *pUnknown, const CCommand &command) +void CmdChangeLevelCallback(const CCommandContext &context, const CCommand &command) { #elif SOURCE_ENGINE >= SE_ORANGEBOX void CmdChangeLevelCallback(const CCommand &command) diff --git a/core/NextMap.h b/core/NextMap.h index 62f496fa..8d614908 100644 --- a/core/NextMap.h +++ b/core/NextMap.h @@ -59,7 +59,7 @@ struct MapChangeData }; #if SOURCE_ENGINE == SE_DOTA -void CmdChangeLevelCallback(void *pUnknown, const CCommand &command); +void CmdChangeLevelCallback(const CCommandContext &context, const CCommand &command); #elif SOURCE_ENGINE >= SE_ORANGEBOX void CmdChangeLevelCallback(const CCommand &command); #else @@ -72,7 +72,7 @@ public: NextMapManager(); #if SOURCE_ENGINE == SE_DOTA - friend void CmdChangeLevelCallback(void *pUnknown, const CCommand &command); + friend void CmdChangeLevelCallback(const CCommandContext &context, const CCommand &command); #elif SOURCE_ENGINE >= SE_ORANGEBOX friend void CmdChangeLevelCallback(const CCommand &command); #else diff --git a/core/PlayerManager.cpp b/core/PlayerManager.cpp index 5a851d22..bb9b8367 100644 --- a/core/PlayerManager.cpp +++ b/core/PlayerManager.cpp @@ -59,11 +59,11 @@ int lifestate_offset = -1; List target_processors; #if SOURCE_ENGINE == SE_DOTA -SH_DECL_HOOK5(IServerGameClients, ClientConnect, SH_NOATTRIB, 0, bool, int, const char *, const char *, char *, int); -SH_DECL_HOOK2_void(IServerGameClients, ClientPutInServer, SH_NOATTRIB, 0, int, const char *); -SH_DECL_HOOK1_void(IServerGameClients, ClientDisconnect, SH_NOATTRIB, 0, int); -SH_DECL_HOOK2_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, int, const CCommand &); -SH_DECL_HOOK1_void(IServerGameClients, ClientSettingsChanged, SH_NOATTRIB, 0, int); +SH_DECL_HOOK5(IServerGameClients, ClientConnect, SH_NOATTRIB, 0, bool, CEntityIndex, const char *, const char *, char *, int); +SH_DECL_HOOK2_void(IServerGameClients, ClientPutInServer, SH_NOATTRIB, 0, CEntityIndex, const char *); +SH_DECL_HOOK1_void(IServerGameClients, ClientDisconnect, SH_NOATTRIB, 0, CEntityIndex); +SH_DECL_HOOK2_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, CEntityIndex, const CCommand &); +SH_DECL_HOOK1_void(IServerGameClients, ClientSettingsChanged, SH_NOATTRIB, 0, CEntityIndex); #else SH_DECL_HOOK5(IServerGameClients, ClientConnect, SH_NOATTRIB, 0, bool, edict_t *, const char *, const char *, char *, int); SH_DECL_HOOK2_void(IServerGameClients, ClientPutInServer, SH_NOATTRIB, 0, edict_t *, const char *); @@ -83,7 +83,7 @@ SH_DECL_HOOK3_void(IServerGameDLL, ServerActivate, SH_NOATTRIB, 0, edict_t *, in #endif #if SOURCE_ENGINE == SE_DOTA -SH_DECL_EXTERN2_void(ConCommand, Dispatch, SH_NOATTRIB, false, void *, const CCommand &); +SH_DECL_EXTERN2_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommandContext &, const CCommand &); #elif SOURCE_ENGINE >= SE_ORANGEBOX SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &); #elif SOURCE_ENGINE == SE_DARKMESSIAH @@ -470,8 +470,9 @@ void PlayerManager::RunAuthChecks() } #if SOURCE_ENGINE == SE_DOTA -bool PlayerManager::OnClientConnect(int client, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen) +bool PlayerManager::OnClientConnect(CEntityIndex index, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen) { + int client = index.Get(); edict_t *pEntity = PEntityOfEntIndex(client); #else bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen) @@ -535,8 +536,9 @@ bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const } #if SOURCE_ENGINE == SE_DOTA -bool PlayerManager::OnClientConnect_Post(int client, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen) +bool PlayerManager::OnClientConnect_Post(CEntityIndex index, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen) { + int client = index.Get(); edict_t *pEntity = PEntityOfEntIndex(client); #else bool PlayerManager::OnClientConnect_Post(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen) @@ -581,8 +583,9 @@ bool PlayerManager::OnClientConnect_Post(edict_t *pEntity, const char *pszName, } #if SOURCE_ENGINE == SE_DOTA -void PlayerManager::OnClientPutInServer(int client, const char *playername) +void PlayerManager::OnClientPutInServer(CEntityIndex index, const char *playername) { + int client = index.Get(); edict_t *pEntity = PEntityOfEntIndex(client); #else void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername) @@ -763,8 +766,9 @@ void PlayerManager::OnSourceModLevelEnd() } #if SOURCE_ENGINE == SE_DOTA -void PlayerManager::OnClientDisconnect(int client) +void PlayerManager::OnClientDisconnect(CEntityIndex index) { + int client = index.Get(); edict_t *pEntity = PEntityOfEntIndex(client); #else void PlayerManager::OnClientDisconnect(edict_t *pEntity) @@ -808,8 +812,9 @@ void PlayerManager::OnClientDisconnect(edict_t *pEntity) } #if SOURCE_ENGINE == SE_DOTA -void PlayerManager::OnClientDisconnect_Post(int client) +void PlayerManager::OnClientDisconnect_Post(CEntityIndex index) { + int client = index.Get(); edict_t *pEntity = PEntityOfEntIndex(client); #else void PlayerManager::OnClientDisconnect_Post(edict_t *pEntity) @@ -850,7 +855,7 @@ void ClientConsolePrint(edict_t *e, const char *fmt, ...) } #if SOURCE_ENGINE == SE_DOTA - engine->ClientPrintf(IndexOfEdict(e), buffer); + engine->ClientPrintf(CEntityIndex(IndexOfEdict(e)), buffer); #else engine->ClientPrintf(e, buffer); #endif @@ -1017,8 +1022,9 @@ void ListPluginsToClient(CPlayer *player, const CCommand &args) } #if SOURCE_ENGINE == SE_DOTA -void PlayerManager::OnClientCommand(int client, const CCommand &args) +void PlayerManager::OnClientCommand(CEntityIndex index, const CCommand &args) { + int client = index.Get(); edict_t *pEntity = PEntityOfEntIndex(client); #elif SOURCE_ENGINE >= SE_ORANGEBOX void PlayerManager::OnClientCommand(edict_t *pEntity, const CCommand &args) @@ -1141,8 +1147,9 @@ void PlayerManager::OnClientCommand(edict_t *pEntity) } #if SOURCE_ENGINE == SE_DOTA -void PlayerManager::OnClientSettingsChanged(int client) +void PlayerManager::OnClientSettingsChanged(CEntityIndex index) { + int client = index.Get(); edict_t *pEntity = PEntityOfEntIndex(client); #else void PlayerManager::OnClientSettingsChanged(edict_t *pEntity) @@ -1805,7 +1812,7 @@ int PlayerManager::GetClientFromSerial(unsigned int serial) } #if SOURCE_ENGINE == SE_DOTA -void CmdMaxplayersCallback(void *pUnknown, const CCommand &command) +void CmdMaxplayersCallback(const CCommandContext &context, const CCommand &command) { #elif SOURCE_ENGINE >= SE_ORANGEBOX void CmdMaxplayersCallback(const CCommand &command) diff --git a/core/PlayerManager.h b/core/PlayerManager.h index f8b0c582..f88f080d 100644 --- a/core/PlayerManager.h +++ b/core/PlayerManager.h @@ -152,14 +152,14 @@ public: void ClearAllAdmins(); public: #if SOURCE_ENGINE == SE_DOTA - bool OnClientConnect(int client, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen); - bool OnClientConnect_Post(int client, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen); - void OnClientPutInServer(int client, char const *playername); - void OnClientDisconnect(int client); - void OnClientDisconnect_Post(int client); - void OnClientCommand(int client, const CCommand &args); - void OnClientSettingsChanged(int client); - //void OnClientSettingsChanged_Pre(int client); + bool OnClientConnect(CEntityIndex index, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen); + bool OnClientConnect_Post(CEntityIndex index, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen); + void OnClientPutInServer(CEntityIndex index, char const *playername); + void OnClientDisconnect(CEntityIndex index); + void OnClientDisconnect_Post(CEntityIndex index); + void OnClientCommand(CEntityIndex index, const CCommand &args); + void OnClientSettingsChanged(CEntityIndex index); + //void OnClientSettingsChanged_Pre(CEntityIndex client); #else bool OnClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen); bool OnClientConnect_Post(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen); @@ -247,7 +247,7 @@ private: }; #if SOURCE_ENGINE == SE_DOTA -void CmdMaxplayersCallback(void *, const CCommand &command); +void CmdMaxplayersCallback(const CCommandContext &context, const CCommand &command); #elif SOURCE_ENGINE >= SE_ORANGEBOX void CmdMaxplayersCallback(const CCommand &command); #else diff --git a/core/convar_sm_dota.h b/core/convar_sm_dota.h index e58eceaa..4e3fd609 100644 --- a/core/convar_sm_dota.h +++ b/core/convar_sm_dota.h @@ -49,6 +49,22 @@ class ConCommand; class ConCommandBase; struct characterset_t; +struct CCommandContext +{ + CCommandContext( int index ) + { + _index = index; + } + + int Get() const + { + return _index; + } + +private: + int _index; +}; + //----------------------------------------------------------------------------- @@ -76,7 +92,7 @@ void ConVar_PublishToVXConsole(); // Called when a ConCommand needs to execute //----------------------------------------------------------------------------- typedef void ( *FnCommandCallbackV1_t )( void ); -typedef void ( *FnCommandCallback_t )( void *pUnknown, const CCommand &command ); +typedef void ( *FnCommandCallback_t )( const CCommandContext &context, const CCommand &command ); #define COMMAND_COMPLETION_MAXITEMS 64 #define COMMAND_COMPLETION_ITEM_LENGTH 64 @@ -99,7 +115,7 @@ public: class ICommandCallback2 { public: - virtual void CommandCallback( void *pUnknown, const CCommand &command ) = 0; + virtual void CommandCallback( const CCommandContext &context, const CCommand &command ) = 0; }; class ICommandCompletionCallback @@ -307,7 +323,7 @@ public: virtual bool CanAutoComplete( void ); // Invoke the function - virtual void Dispatch( void *pUnknown, const CCommand &command ); + virtual void Dispatch( const CCommandContext &context, const CCommand &command ); private: // NOTE: To maintain backward compat, we have to be very careful: @@ -962,71 +978,71 @@ private: // Purpose: Utility macros to quicky generate a simple console command //----------------------------------------------------------------------------- #define CON_COMMAND( name, description ) \ - static void name( void *pUnknown, const CCommand &args ); \ + static void name( const CCommandContext &context, const CCommand &args ); \ static ConCommand name##_command( #name, name, description ); \ - static void name( void *pUnknown, const CCommand &args ) + static void name( const CCommandContext &context, const CCommand &args ) #ifdef CLIENT_DLL #define CON_COMMAND_SHARED( name, description ) \ - static void name( void *pUnknown, const CCommand &args ); \ + static void name( const CCommandContext &context, const CCommand &args ); \ static ConCommand name##_command_client( #name "_client", name, description ); \ - static void name( void *pUnknown, const CCommand &args ) + static void name( const CCommandContext &context, const CCommand &args ) #else #define CON_COMMAND_SHARED( name, description ) \ - static void name( void *pUnknown, const CCommand &args ); \ + static void name( const CCommandContext &context, const CCommand &args ); \ static ConCommand name##_command( #name, name, description ); \ - static void name( void *pUnknown, const CCommand &args ) + static void name( const CCommandContext &context, const CCommand &args ) #endif #define CON_COMMAND_F( name, description, flags ) \ - static void name( void *pUnknown, const CCommand &args ); \ + static void name( const CCommandContext &context, const CCommand &args ); \ static ConCommand name##_command( #name, name, description, flags ); \ - static void name( void *pUnknown, const CCommand &args ) + static void name( const CCommandContext &context, const CCommand &args ) #ifdef CLIENT_DLL #define CON_COMMAND_F_SHARED( name, description, flags ) \ - static void name( void *pUnknown, const CCommand &args ); \ + static void name( const CCommandContext &context, const CCommand &args ); \ static ConCommand name##_command_client( #name "_client", name, description, flags ); \ - static void name( void *pUnknown, const CCommand &args ) + static void name( const CCommandContext &context, const CCommand &args ) #else #define CON_COMMAND_F_SHARED( name, description, flags ) \ - static void name( void *pUnknown, const CCommand &args ); \ + static void name( const CCommandContext &context, const CCommand &args ); \ static ConCommand name##_command( #name, name, description, flags ); \ - static void name( void *pUnknown, const CCommand &args ) + static void name( const CCommandContext &context, const CCommand &args ) #endif #define CON_COMMAND_F_COMPLETION( name, description, flags, completion ) \ - static void name( void *pUnknown, const CCommand &args ); \ + static void name( const CCommandContext &context, const CCommand &args ); \ static ConCommand name##_command( #name, name, description, flags, completion ); \ - static void name( void *pUnknown, const CCommand &args ) + static void name( const CCommandContext &context, const CCommand &args ) #ifdef CLIENT_DLL #define CON_COMMAND_F_COMPLETION_SHARED( name, description, flags, completion ) \ - static void name( void *pUnknown, const CCommand &args ); \ + static void name( const CCommandContext &context, const CCommand &args ); \ static ConCommand name##_command_client( #name "_client", name, description, flags, completion ); \ - static void name( void *pUnknown, const CCommand &args ) + static void name( const CCommandContext &context, const CCommand &args ) #else #define CON_COMMAND_F_COMPLETION_SHARED( name, description, flags, completion ) \ - static void name( void *pUnknown, const CCommand &args ); \ + static void name( const CCommandContext &context, const CCommand &args ); \ static ConCommand name##_command( #name, name, description, flags, completion ); \ - static void name( void *pUnknown, const CCommand &args ) + static void name( const CCommandContext &context, const CCommand &args ) #endif #define CON_COMMAND_EXTERN( name, _funcname, description ) \ - void _funcname( void *pUnknown, const CCommand &args ); \ + void _funcname( const CCommandContext &context, const CCommand &args ); \ static ConCommand name##_command( #name, _funcname, description ); \ - void _funcname( void *pUnknown, const CCommand &args ) + void _funcname( const CCommandContext &context, const CCommand &args ) #define CON_COMMAND_EXTERN_F( name, _funcname, description, flags ) \ - void _funcname( void *pUnknown, const CCommand &args ); \ + void _funcname( const CCommandContext &context, const CCommand &args ); \ static ConCommand name##_command( #name, _funcname, description, flags ); \ - void _funcname( void *pUnknown, const CCommand &args ) + void _funcname( const CCommandContext &context, const CCommand &args ) #define CON_COMMAND_MEMBER_F( _thisclass, name, _funcname, description, flags ) \ - void _funcname( void *pUnknown, const CCommand &args ); \ + void _funcname( const CCommandContext &context, const CCommand &args ); \ friend class CCommandMemberInitializer_##_funcname; \ class CCommandMemberInitializer_##_funcname \ { \ diff --git a/core/smn_halflife.cpp b/core/smn_halflife.cpp index ff19e378..05394a81 100644 --- a/core/smn_halflife.cpp +++ b/core/smn_halflife.cpp @@ -103,8 +103,7 @@ static cell_t CreateFakeClient(IPluginContext *pContext, const cell_t *params) pContext->LocalToString(params[1], &netname); #if SOURCE_ENGINE == SE_DOTA - int index; - engine->CreateFakeClient(&index, netname); + int index = engine->CreateFakeClient(netname).Get(); if (index == -1) { diff --git a/core/smn_usermsgs.cpp b/core/smn_usermsgs.cpp index 876e8a7e..d8e5995f 100644 --- a/core/smn_usermsgs.cpp +++ b/core/smn_usermsgs.cpp @@ -270,7 +270,7 @@ size_t MsgListenerWrapper::_FillInPlayers(int *pl_array, IRecipientFilter *pFilt { int index; #if SOURCE_ENGINE == SE_DOTA - pFilter->GetRecipientIndex(&index, i); + index = pFilter->GetRecipientIndex(i).Get(); #else index = pFilter->GetRecipientIndex(i); #endif diff --git a/extensions/sdktools/CellRecipientFilter.h b/extensions/sdktools/CellRecipientFilter.h index 0ed4d147..d71ffe8d 100644 --- a/extensions/sdktools/CellRecipientFilter.h +++ b/extensions/sdktools/CellRecipientFilter.h @@ -45,7 +45,7 @@ public: //IRecipientFilter bool IsInitMessage() const; int GetRecipientCount() const; #if SOURCE_ENGINE == SE_DOTA - void GetRecipientIndex(int *clientIndex, int slot) const; + CEntityIndex GetRecipientIndex(int slot) const; #else int GetRecipientIndex(int slot) const; #endif @@ -84,7 +84,7 @@ inline int CellRecipientFilter::GetRecipientCount() const } #if SOURCE_ENGINE == SE_DOTA -inline void CellRecipientFilter::GetRecipientIndex(int *clientIndex, int slot) const +inline CEntityIndex CellRecipientFilter::GetRecipientIndex(int slot) const #else inline int CellRecipientFilter::GetRecipientIndex(int slot) const #endif @@ -97,7 +97,7 @@ inline int CellRecipientFilter::GetRecipientIndex(int slot) const ret = static_cast(m_Players[slot]); #if SOURCE_ENGINE == SE_DOTA - *clientIndex = ret; + return CEntityIndex(ret); #else return ret; #endif diff --git a/extensions/sdktools/extension.h b/extensions/sdktools/extension.h index 216a9a80..d1c99d47 100644 --- a/extensions/sdktools/extension.h +++ b/extensions/sdktools/extension.h @@ -94,7 +94,7 @@ public: // IVoiceServer bool OnSetClientListening(int iReceiver, int iSender, bool bListen); void VoiceInit(); #if SOURCE_ENGINE == SE_DOTA - void OnClientCommand(int client, const CCommand &args); + void OnClientCommand(CEntityIndex index, const CCommand &args); #elif SOURCE_ENGINE >= SE_ORANGEBOX void OnClientCommand(edict_t *pEntity, const CCommand &args); #else diff --git a/extensions/sdktools/tenatives.cpp b/extensions/sdktools/tenatives.cpp index d589f7c5..9d14d466 100644 --- a/extensions/sdktools/tenatives.cpp +++ b/extensions/sdktools/tenatives.cpp @@ -140,7 +140,7 @@ size_t TempEntHooks::_FillInPlayers(int *pl_array, IRecipientFilter *pFilter) { int index; #if SOURCE_ENGINE == SE_DOTA - pFilter->GetRecipientIndex(&index, i); + index = pFilter->GetRecipientIndex(i).Get(); #else index = pFilter->GetRecipientIndex(i); #endif diff --git a/extensions/sdktools/voice.cpp b/extensions/sdktools/voice.cpp index 54a7ce76..3c4ffd97 100644 --- a/extensions/sdktools/voice.cpp +++ b/extensions/sdktools/voice.cpp @@ -59,7 +59,7 @@ bool g_ClientMutes[65][65]; SH_DECL_HOOK3(IVoiceServer, SetClientListening, SH_NOATTRIB, 0, bool, int, int, bool); #if SOURCE_ENGINE == SE_DOTA -SH_DECL_HOOK2_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, int, const CCommand &); +SH_DECL_HOOK2_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, CEntityIndex, const CCommand &); #elif SOURCE_ENGINE >= SE_ORANGEBOX SH_DECL_HOOK2_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t *, const CCommand &); #else @@ -94,8 +94,9 @@ void SDKTools::VoiceInit() } #if SOURCE_ENGINE == SE_DOTA -void SDKTools::OnClientCommand(int client, const CCommand &args) +void SDKTools::OnClientCommand(CEntityIndex index, const CCommand &args) { + int client = index.Get(); #elif SOURCE_ENGINE >= SE_ORANGEBOX void SDKTools::OnClientCommand(edict_t *pEntity, const CCommand &args) { diff --git a/extensions/sdktools/vsound.cpp b/extensions/sdktools/vsound.cpp index 30e5b291..afdd67c1 100644 --- a/extensions/sdktools/vsound.cpp +++ b/extensions/sdktools/vsound.cpp @@ -32,7 +32,12 @@ #include "vsound.h" #include +#if SOURCE_ENGINE == SE_DOTA +SH_DECL_HOOK8_void(IVEngineServer, EmitAmbientSound, SH_NOATTRIB, 0, CEntityIndex, const Vector &, const char *, float, soundlevel_t, int, int, float); +#else SH_DECL_HOOK8_void(IVEngineServer, EmitAmbientSound, SH_NOATTRIB, 0, int, const Vector &, const char *, float, soundlevel_t, int, int, float); +#endif + #if SOURCE_ENGINE >= SE_PORTAL2 SH_DECL_HOOK17(IEngineSound, EmitSound, SH_NOATTRIB, 0, int, IRecipientFilter &, int, int, const char *, unsigned int, const char *, float, float, int, int, int, const Vector *, const Vector *, CUtlVector *, bool, float, int); SH_DECL_HOOK17(IEngineSound, EmitSound, SH_NOATTRIB, 1, int, IRecipientFilter &, int, int, const char *, unsigned int, const char *, float, soundlevel_t, int, int, int, const Vector *, const Vector *, CUtlVector *, bool, float, int); @@ -70,7 +75,7 @@ size_t SoundHooks::_FillInPlayers(int *pl_array, IRecipientFilter *pFilter) { int index; #if SOURCE_ENGINE == SE_DOTA - pFilter->GetRecipientIndex(&index, i); + index = pFilter->GetRecipientIndex(i).Get(); #else index = pFilter->GetRecipientIndex(i); #endif @@ -221,9 +226,16 @@ bool SoundHooks::RemoveHook(int type, IPluginFunction *pFunc) return false; } +#if SOURCE_ENGINE == SE_DOTA +void SoundHooks::OnEmitAmbientSound(CEntityIndex index, const Vector &pos, const char *samp, float vol, + soundlevel_t soundlevel, int fFlags, int pitch, float delay) +{ + int entindex = index.Get(); +#else void SoundHooks::OnEmitAmbientSound(int entindex, const Vector &pos, const char *samp, float vol, soundlevel_t soundlevel, int fFlags, int pitch, float delay) { +#endif SoundHookIter iter; IPluginFunction *pFunc; cell_t vec[3] = {sp_ftoc(pos.x), sp_ftoc(pos.y), sp_ftoc(pos.z)}; @@ -259,8 +271,13 @@ void SoundHooks::OnEmitAmbientSound(int entindex, const Vector &pos, const char vec2.x = sp_ctof(vec[0]); vec2.y = sp_ctof(vec[1]); vec2.z = sp_ctof(vec[2]); +#if SOURCE_ENGINE == SE_DOTA RETURN_META_NEWPARAMS(MRES_IGNORED, &IVEngineServer::EmitAmbientSound, + (CEntityIndex(entindex), vec2, buffer, vol, soundlevel, fFlags, pitch, delay)); +#else + RETURN_META_NEWPARAMS(MRES_IGNORED, &IVEngineServer::EmitAmbientSound, (entindex, vec2, buffer, vol, soundlevel, fFlags, pitch, delay)); +#endif } } } diff --git a/extensions/sdktools/vsound.h b/extensions/sdktools/vsound.h index 018227bf..96fc087f 100644 --- a/extensions/sdktools/vsound.h +++ b/extensions/sdktools/vsound.h @@ -50,8 +50,14 @@ public: void Shutdown(); void AddHook(int type, IPluginFunction *pFunc); bool RemoveHook(int type, IPluginFunction *pFunc); -#if SOURCE_ENGINE >= SE_PORTAL2 + +#if SOURCE_ENGINE == SE_DOTA + void OnEmitAmbientSound(CEntityIndex index, const Vector &pos, const char *samp, float vol, soundlevel_t soundlevel, int fFlags, int pitch, float delay); +#else void OnEmitAmbientSound(int entindex, const Vector &pos, const char *samp, float vol, soundlevel_t soundlevel, int fFlags, int pitch, float delay); +#endif + +#if SOURCE_ENGINE >= SE_PORTAL2 int OnEmitSound(IRecipientFilter& filter, int iEntIndex, int iChannel, const char *, unsigned int, const char *pSample, float flVolume, soundlevel_t iSoundlevel, int nSeed, int iFlags, int iPitch, const Vector *pOrigin, const Vector *pDirection, CUtlVector *pUtlVecOrigins, bool bUpdatePositions, @@ -61,8 +67,6 @@ public: const Vector *pDirection, CUtlVector *pUtlVecOrigins, bool bUpdatePositions, float soundtime, int speakerentity); #else - void OnEmitAmbientSound(int entindex, const Vector &pos, const char *samp, float vol, - soundlevel_t soundlevel, int fFlags, int pitch, float delay); #if SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS void OnEmitSound(IRecipientFilter& filter, int iEntIndex, int iChannel, const char *pSample, float flVolume,