Updated for latest hl2sdk-dota changes.

This commit is contained in:
Nicholas Hastings 2013-05-13 15:18:12 -04:00
parent e8dc1480eb
commit 614967ccc1
17 changed files with 228 additions and 29 deletions

View File

@ -286,7 +286,7 @@ void ChatTriggers::OnSayCommand_Post()
int client = g_ConCmds.GetCommandClient(); int client = g_ConCmds.GetCommandClient();
unsigned int old = SetReplyTo(SM_REPLY_CHAT); unsigned int old = SetReplyTo(SM_REPLY_CHAT);
#if SOURCE_ENGINE == SE_DOTA #if SOURCE_ENGINE == SE_DOTA
engine->ClientCommand(PEntityOfEntIndex(client), "%s", m_ToExecute); engine->ClientCommand(client, "%s", m_ToExecute);
#else #else
serverpluginhelpers->ClientCommand(PEntityOfEntIndex(client), m_ToExecute); serverpluginhelpers->ClientCommand(PEntityOfEntIndex(client), m_ToExecute);
#endif #endif

View File

@ -539,7 +539,9 @@ bool ConCmdManager::CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmi
return true; return true;
} }
#if SOURCE_ENGINE != SE_DOTA
edict_t *pEdict = PEntityOfEntIndex(client); edict_t *pEdict = PEntityOfEntIndex(client);
#endif
/* If we got here, the command failed... */ /* If we got here, the command failed... */
char buffer[128]; char buffer[128];
@ -553,7 +555,11 @@ bool ConCmdManager::CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmi
{ {
char fullbuffer[192]; char fullbuffer[192];
UTIL_Format(fullbuffer, sizeof(fullbuffer), "[SM] %s.\n", buffer); UTIL_Format(fullbuffer, sizeof(fullbuffer), "[SM] %s.\n", buffer);
#if SOURCE_ENGINE == SE_DOTA
engine->ClientPrintf(client, fullbuffer);
#else
engine->ClientPrintf(pEdict, fullbuffer); engine->ClientPrintf(pEdict, fullbuffer);
#endif
} }
else if (replyto == SM_REPLY_CHAT) else if (replyto == SM_REPLY_CHAT)
{ {

View File

@ -611,7 +611,11 @@ QueryCvarCookie_t ConVarManager::QueryClientConVar(edict_t *pPlayer, const char
/* Call StartQueryCvarValue() in either the IVEngineServer or IServerPluginHelpers depending on situation */ /* Call StartQueryCvarValue() in either the IVEngineServer or IServerPluginHelpers depending on situation */
if (m_bIsDLLQueryHooked) if (m_bIsDLLQueryHooked)
{ {
#if SOURCE_ENGINE == SE_DOTA
cookie = engine->StartQueryCvarValue(IndexOfEdict(pPlayer), name);
#else
cookie = engine->StartQueryCvarValue(pPlayer, name); cookie = engine->StartQueryCvarValue(pPlayer, name);
#endif
} }
#if SOURCE_ENGINE != SE_DOTA #if SOURCE_ENGINE != SE_DOTA
else if (m_bIsVSPQueryHooked) else if (m_bIsVSPQueryHooked)

View File

@ -300,7 +300,11 @@ bool CHalfLife2::IsOriginalEngine()
#if SOURCE_ENGINE != SE_DARKMESSIAH #if SOURCE_ENGINE != SE_DARKMESSIAH
IChangeInfoAccessor *CBaseEdict::GetChangeAccessor() IChangeInfoAccessor *CBaseEdict::GetChangeAccessor()
{ {
#if SOURCE_ENGINE == SE_DOTA
return engine->GetChangeAccessor( IndexOfEdict((const edict_t *)this) );
#else
return engine->GetChangeAccessor( (const edict_t *)this ); return engine->GetChangeAccessor( (const edict_t *)this );
#endif
} }
#endif #endif
@ -792,7 +796,7 @@ void CHalfLife2::ProcessFakeCliCmdQueue()
{ {
CPlayer *pPlayer = g_Players.GetPlayerByIndex(pFake->client); CPlayer *pPlayer = g_Players.GetPlayerByIndex(pFake->client);
#if SOURCE_ENGINE == SE_DOTA #if SOURCE_ENGINE == SE_DOTA
engine->ClientCommand(pPlayer->GetEdict(), "%s", pFake->cmd.c_str()); engine->ClientCommand(pPlayer->GetIndex(), "%s", pFake->cmd.c_str());
#else #else
serverpluginhelpers->ClientCommand(pPlayer->GetEdict(), pFake->cmd.c_str()); serverpluginhelpers->ClientCommand(pPlayer->GetEdict(), pFake->cmd.c_str());
#endif #endif

View File

@ -58,6 +58,13 @@ const unsigned int *g_NumPlayersToAuth = NULL;
int lifestate_offset = -1; int lifestate_offset = -1;
List<ICommandTargetProcessor *> target_processors; List<ICommandTargetProcessor *> 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);
#else
SH_DECL_HOOK5(IServerGameClients, ClientConnect, SH_NOATTRIB, 0, bool, edict_t *, const char *, const char *, char *, int); 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 *); SH_DECL_HOOK2_void(IServerGameClients, ClientPutInServer, SH_NOATTRIB, 0, edict_t *, const char *);
SH_DECL_HOOK1_void(IServerGameClients, ClientDisconnect, SH_NOATTRIB, 0, edict_t *); SH_DECL_HOOK1_void(IServerGameClients, ClientDisconnect, SH_NOATTRIB, 0, edict_t *);
@ -67,6 +74,7 @@ SH_DECL_HOOK2_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t *,
SH_DECL_HOOK1_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t *); SH_DECL_HOOK1_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t *);
#endif #endif
SH_DECL_HOOK1_void(IServerGameClients, ClientSettingsChanged, SH_NOATTRIB, 0, edict_t *); SH_DECL_HOOK1_void(IServerGameClients, ClientSettingsChanged, SH_NOATTRIB, 0, edict_t *);
#endif // SE_DOTA
#if SOURCE_ENGINE == SE_DOTA #if SOURCE_ENGINE == SE_DOTA
SH_DECL_HOOK0_void(IServerGameDLL, ServerActivate, SH_NOATTRIB, 0); SH_DECL_HOOK0_void(IServerGameDLL, ServerActivate, SH_NOATTRIB, 0);
@ -380,7 +388,11 @@ void PlayerManager::RunAuthChecks()
for (unsigned int i=1; i<=m_AuthQueue[0]; i++) for (unsigned int i=1; i<=m_AuthQueue[0]; i++)
{ {
pPlayer = &m_Players[m_AuthQueue[i]]; pPlayer = &m_Players[m_AuthQueue[i]];
#if SOURCE_ENGINE == SE_DOTA
authstr = engine->GetPlayerNetworkIDString(pPlayer->m_iIndex - 1);
#else
authstr = engine->GetPlayerNetworkIDString(pPlayer->m_pEdict); authstr = engine->GetPlayerNetworkIDString(pPlayer->m_pEdict);
#endif
pPlayer->SetAuthString(authstr); pPlayer->SetAuthString(authstr);
if (!pPlayer->IsAuthStringValidated()) if (!pPlayer->IsAuthStringValidated())
@ -457,9 +469,15 @@ void PlayerManager::RunAuthChecks()
} }
} }
#if SOURCE_ENGINE == SE_DOTA
bool PlayerManager::OnClientConnect(int client, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen)
{
edict_t *pEntity = PEntityOfEntIndex(client);
#else
bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen) bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen)
{ {
int client = IndexOfEdict(pEntity); int client = IndexOfEdict(pEntity);
#endif
CPlayer *pPlayer = &m_Players[client]; CPlayer *pPlayer = &m_Players[client];
++m_PlayersSinceActive; ++m_PlayersSinceActive;
@ -503,7 +521,7 @@ bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const
m_AuthQueue[++m_AuthQueue[0]] = client; m_AuthQueue[++m_AuthQueue[0]] = client;
} }
m_UserIdLookUp[engine->GetPlayerUserId(pEntity)] = client; m_UserIdLookUp[GetPlayerUserId(pEntity)] = client;
} }
else else
{ {
@ -516,9 +534,16 @@ bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const
return true; return true;
} }
#if SOURCE_ENGINE == SE_DOTA
bool PlayerManager::OnClientConnect_Post(int client, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen)
{
edict_t *pEntity = PEntityOfEntIndex(client);
#else
bool PlayerManager::OnClientConnect_Post(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen) bool PlayerManager::OnClientConnect_Post(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen)
{ {
int client = IndexOfEdict(pEntity); int client = IndexOfEdict(pEntity);
#endif
bool orig_value = META_RESULT_ORIG_RET(bool); bool orig_value = META_RESULT_ORIG_RET(bool);
CPlayer *pPlayer = &m_Players[client]; CPlayer *pPlayer = &m_Players[client];
@ -555,10 +580,17 @@ bool PlayerManager::OnClientConnect_Post(edict_t *pEntity, const char *pszName,
return true; return true;
} }
#if SOURCE_ENGINE == SE_DOTA
void PlayerManager::OnClientPutInServer(int client, const char *playername)
{
edict_t *pEntity = PEntityOfEntIndex(client);
#else
void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername) void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername)
{ {
cell_t res;
int client = IndexOfEdict(pEntity); int client = IndexOfEdict(pEntity);
#endif
cell_t res;
CPlayer *pPlayer = &m_Players[client]; CPlayer *pPlayer = &m_Players[client];
/* If they're not connected, they're a bot */ /* If they're not connected, they're a bot */
@ -566,7 +598,12 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername
{ {
/* Run manual connection routines */ /* Run manual connection routines */
char error[255]; char error[255];
const char *authid = engine->GetPlayerNetworkIDString(pEntity); const char *authid;
#if SOURCE_ENGINE == SE_DOTA
authid = engine->GetPlayerNetworkIDString(client - 1);
#else
authid = engine->GetPlayerNetworkIDString(pEntity);
#endif
pPlayer->SetAuthString(authid); pPlayer->SetAuthString(authid);
pPlayer->Authorize(); pPlayer->Authorize();
pPlayer->m_bFakeClient = true; pPlayer->m_bFakeClient = true;
@ -593,7 +630,7 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername
// This doesn't actually get incremented until OnClientConnect. Fake it to check. // This doesn't actually get incremented until OnClientConnect. Fake it to check.
int newCount = m_PlayersSinceActive + 1; int newCount = m_PlayersSinceActive + 1;
int userId = engine->GetPlayerUserId(pEntity); int userId = GetPlayerUserId(pEntity);
#if (SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_LEFT4DEAD2) #if (SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_LEFT4DEAD2)
static ConVar *tv_name = icvar->FindVar("tv_name"); static ConVar *tv_name = icvar->FindVar("tv_name");
#endif #endif
@ -717,10 +754,17 @@ void PlayerManager::OnSourceModLevelEnd()
m_PlayerCount = 0; m_PlayerCount = 0;
} }
#if SOURCE_ENGINE == SE_DOTA
void PlayerManager::OnClientDisconnect(int client)
{
edict_t *pEntity = PEntityOfEntIndex(client);
#else
void PlayerManager::OnClientDisconnect(edict_t *pEntity) void PlayerManager::OnClientDisconnect(edict_t *pEntity)
{ {
cell_t res;
int client = IndexOfEdict(pEntity); int client = IndexOfEdict(pEntity);
#endif
cell_t res;
CPlayer *pPlayer = &m_Players[client]; CPlayer *pPlayer = &m_Players[client];
if (pPlayer->IsConnected()) if (pPlayer->IsConnected())
@ -755,10 +799,17 @@ void PlayerManager::OnClientDisconnect(edict_t *pEntity)
} }
} }
#if SOURCE_ENGINE == SE_DOTA
void PlayerManager::OnClientDisconnect_Post(int client)
{
edict_t *pEntity = PEntityOfEntIndex(client);
#else
void PlayerManager::OnClientDisconnect_Post(edict_t *pEntity) void PlayerManager::OnClientDisconnect_Post(edict_t *pEntity)
{ {
cell_t res;
int client = IndexOfEdict(pEntity); int client = IndexOfEdict(pEntity);
#endif
cell_t res;
m_cldisconnect_post->PushCell(client); m_cldisconnect_post->PushCell(client);
m_cldisconnect_post->Execute(&res, NULL); m_cldisconnect_post->Execute(&res, NULL);
@ -790,7 +841,11 @@ void ClientConsolePrint(edict_t *e, const char *fmt, ...)
buffer[len] = '\0'; buffer[len] = '\0';
} }
#if SOURCE_ENGINE == SE_DOTA
engine->ClientPrintf(IndexOfEdict(e), buffer);
#else
engine->ClientPrintf(e, buffer); engine->ClientPrintf(e, buffer);
#endif
} }
void ListExtensionsToClient(CPlayer *player, const CCommand &args) void ListExtensionsToClient(CPlayer *player, const CCommand &args)
@ -953,15 +1008,22 @@ void ListPluginsToClient(CPlayer *player, const CCommand &args)
} }
} }
#if SOURCE_ENGINE >= SE_ORANGEBOX #if SOURCE_ENGINE == SE_DOTA
void PlayerManager::OnClientCommand(int client, const CCommand &args)
{
edict_t *pEntity = PEntityOfEntIndex(client);
#elif SOURCE_ENGINE >= SE_ORANGEBOX
void PlayerManager::OnClientCommand(edict_t *pEntity, const CCommand &args) void PlayerManager::OnClientCommand(edict_t *pEntity, const CCommand &args)
{ {
int client = IndexOfEdict(pEntity);
#else #else
void PlayerManager::OnClientCommand(edict_t *pEntity) void PlayerManager::OnClientCommand(edict_t *pEntity)
{ {
CCommand args; CCommand args;
#endif
int client = IndexOfEdict(pEntity); int client = IndexOfEdict(pEntity);
#endif
cell_t res = Pl_Continue; cell_t res = Pl_Continue;
CPlayer *pPlayer = &m_Players[client]; CPlayer *pPlayer = &m_Players[client];
@ -1070,10 +1132,17 @@ void PlayerManager::OnClientCommand(edict_t *pEntity)
} }
} }
#if SOURCE_ENGINE == SE_DOTA
void PlayerManager::OnClientSettingsChanged(int client)
{
edict_t *pEntity = PEntityOfEntIndex(client);
#else
void PlayerManager::OnClientSettingsChanged(edict_t *pEntity) void PlayerManager::OnClientSettingsChanged(edict_t *pEntity)
{ {
cell_t res;
int client = IndexOfEdict(pEntity); int client = IndexOfEdict(pEntity);
#endif
cell_t res;
CPlayer *pPlayer = &m_Players[client]; CPlayer *pPlayer = &m_Players[client];
if (!pPlayer->IsConnected()) if (!pPlayer->IsConnected())
@ -1193,7 +1262,7 @@ int PlayerManager::GetClientOfUserId(int userid)
CPlayer *player = GetPlayerByIndex(client); CPlayer *player = GetPlayerByIndex(client);
if (player && player->IsConnected()) if (player && player->IsConnected())
{ {
int realUserId = engine->GetPlayerUserId(player->GetEdict()); int realUserId = GetPlayerUserId(player->GetEdict());
if (realUserId == userid) if (realUserId == userid)
{ {
return client; return client;
@ -1210,7 +1279,7 @@ int PlayerManager::GetClientOfUserId(int userid)
{ {
continue; continue;
} }
if (engine->GetPlayerUserId(player->GetEdict()) == userid) if (GetPlayerUserId(player->GetEdict()) == userid)
{ {
m_UserIdLookUp[userid] = i; m_UserIdLookUp[userid] = i;
return i; return i;
@ -1324,7 +1393,7 @@ void PlayerManager::InvalidatePlayer(CPlayer *pPlayer)
} }
} }
m_UserIdLookUp[engine->GetPlayerUserId(pPlayer->m_pEdict)] = 0; m_UserIdLookUp[GetPlayerUserId(pPlayer->m_pEdict)] = 0;
pPlayer->Disconnect(); pPlayer->Disconnect();
} }
@ -1897,7 +1966,13 @@ unsigned int CPlayer::GetSteamAccountID(bool validated)
m_SteamAccountID = (atoi(&pAuth[8]) | (atoi(&pAuth[10]) << 1)); m_SteamAccountID = (atoi(&pAuth[8]) | (atoi(&pAuth[10]) << 1));
} }
#else #else
unsigned long long *steamId = (unsigned long long *)engine->GetClientSteamID(m_pEdict); unsigned long long *steamId;
#if SOURCE_ENGINE == SE_DOTA
steamId = (unsigned long long *)engine->GetClientSteamID(m_iIndex);
#else
steamId = (unsigned long long *)engine->GetClientSteamID(m_pEdict);
#endif
if (steamId) if (steamId)
{ {
m_SteamAccountID = (*steamId & 0xFFFFFFFF); m_SteamAccountID = (*steamId & 0xFFFFFFFF);
@ -1911,6 +1986,11 @@ edict_t *CPlayer::GetEdict()
return m_pEdict; return m_pEdict;
} }
int CPlayer::GetIndex() const
{
return m_iIndex;
}
bool CPlayer::IsInGame() bool CPlayer::IsInGame()
{ {
return m_IsInGame && (m_pEdict->GetUnknown() != NULL); return m_IsInGame && (m_pEdict->GetUnknown() != NULL);
@ -1936,7 +2016,11 @@ bool CPlayer::IsAuthStringValidated()
#if SOURCE_ENGINE >= SE_ORANGEBOX #if SOURCE_ENGINE >= SE_ORANGEBOX
if (g_Players.m_bAuthstringValidation && !g_HL2.IsLANServer()) if (g_Players.m_bAuthstringValidation && !g_HL2.IsLANServer())
{ {
#if SOURCE_ENGINE == SE_DOTA
return engine->IsClientFullyAuthenticated(m_iIndex);
#else
return engine->IsClientFullyAuthenticated(m_pEdict); return engine->IsClientFullyAuthenticated(m_pEdict);
#endif
} }
#endif #endif
@ -2130,7 +2214,7 @@ void CPlayer::DoBasicAdminChecks()
{ {
if (!g_Players.CheckSetAdminName(client, this, id)) if (!g_Players.CheckSetAdminName(client, this, id))
{ {
int userid = engine->GetPlayerUserId(m_pEdict); int userid = GetPlayerUserId(m_pEdict);
g_Timers.CreateTimer(&s_KickPlayerTimer, 0.1f, (void *)userid, 0); g_Timers.CreateTimer(&s_KickPlayerTimer, 0.1f, (void *)userid, 0);
} }
return; return;
@ -2169,7 +2253,7 @@ int CPlayer::GetUserId()
{ {
if (m_UserId == -1) if (m_UserId == -1)
{ {
m_UserId = engine->GetPlayerUserId(GetEdict()); m_UserId = GetPlayerUserId(GetEdict());
} }
return m_UserId; return m_UserId;

View File

@ -90,6 +90,7 @@ public:
bool RunAdminCacheChecks(); bool RunAdminCacheChecks();
void NotifyPostAdminChecks(); void NotifyPostAdminChecks();
unsigned int GetSerial(); unsigned int GetSerial();
int GetIndex() const;
public: public:
void DoBasicAdminChecks(); void DoBasicAdminChecks();
void MarkAsBeingKicked(); void MarkAsBeingKicked();
@ -150,6 +151,16 @@ public:
void ClearAdminId(AdminId id); void ClearAdminId(AdminId id);
void ClearAllAdmins(); void ClearAllAdmins();
public: 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);
#else
bool OnClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen); 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); bool OnClientConnect_Post(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen);
void OnClientPutInServer(edict_t *pEntity, char const *playername); void OnClientPutInServer(edict_t *pEntity, char const *playername);
@ -162,6 +173,7 @@ public:
#endif #endif
void OnClientSettingsChanged(edict_t *pEntity); void OnClientSettingsChanged(edict_t *pEntity);
//void OnClientSettingsChanged_Pre(edict_t *pEntity); //void OnClientSettingsChanged_Pre(edict_t *pEntity);
#endif
public: //IPlayerManager public: //IPlayerManager
void AddClientListener(IClientListener *listener); void AddClientListener(IClientListener *listener);
void RemoveClientListener(IClientListener *listener); void RemoveClientListener(IClientListener *listener);

View File

@ -1130,7 +1130,7 @@ reswitch:
{ {
auth = "STEAM_ID_PENDING"; auth = "STEAM_ID_PENDING";
} }
int userid = engine->GetPlayerUserId(player->GetEdict()); int userid = GetPlayerUserId(player->GetEdict());
UTIL_Format(buffer, UTIL_Format(buffer,
sizeof(buffer), sizeof(buffer),
"%s<%d><%s><>", "%s<%d><%s><>",

View File

@ -878,7 +878,11 @@ static cell_t sm_PrintToConsole(IPluginContext *pCtx, const cell_t *params)
if (index != 0) if (index != 0)
{ {
#if SOURCE_ENGINE == SE_DOTA
engine->ClientPrintf(pPlayer->GetIndex(), buffer);
#else
engine->ClientPrintf(pPlayer->GetEdict(), buffer); engine->ClientPrintf(pPlayer->GetEdict(), buffer);
#endif
} else { } else {
META_CONPRINT(buffer); META_CONPRINT(buffer);
} }
@ -1077,7 +1081,13 @@ static cell_t sm_ClientCommand(IPluginContext *pContext, const cell_t *params)
return 0; return 0;
} }
engine->ClientCommand(pPlayer->GetEdict(), "%s", buffer); engine->ClientCommand(
#if SOURCE_ENGINE == SE_DOTA
pPlayer->GetIndex(),
#else
pPlayer->GetEdict(),
#endif
"%s", buffer);
return 1; return 1;
} }
@ -1105,7 +1115,7 @@ static cell_t FakeClientCommand(IPluginContext *pContext, const cell_t *params)
} }
#if SOURCE_ENGINE == SE_DOTA #if SOURCE_ENGINE == SE_DOTA
engine->ClientCommand(pPlayer->GetEdict(), "%s", buffer); engine->ClientCommand(pPlayer->GetIndex(), "%s", buffer);
#else #else
serverpluginhelpers->ClientCommand(pPlayer->GetEdict(), buffer); serverpluginhelpers->ClientCommand(pPlayer->GetEdict(), buffer);
#endif #endif
@ -1135,7 +1145,7 @@ static cell_t FakeClientCommandEx(IPluginContext *pContext, const cell_t *params
return 0; return 0;
} }
g_HL2.AddToFakeCliCmdQueue(params[1], engine->GetPlayerUserId(pPlayer->GetEdict()), buffer); g_HL2.AddToFakeCliCmdQueue(params[1], GetPlayerUserId(pPlayer->GetEdict()), buffer);
return 1; return 1;
} }
@ -1182,7 +1192,11 @@ static cell_t ReplyToCommand(IPluginContext *pContext, const cell_t *params)
{ {
buffer[len++] = '\n'; buffer[len++] = '\n';
buffer[len] = '\0'; buffer[len] = '\0';
#if SOURCE_ENGINE == SE_DOTA
engine->ClientPrintf(pPlayer->GetIndex(), buffer);
#else
engine->ClientPrintf(pPlayer->GetEdict(), buffer); engine->ClientPrintf(pPlayer->GetEdict(), buffer);
#endif
} else if (replyto == SM_REPLY_CHAT) { } else if (replyto == SM_REPLY_CHAT) {
if (len >= 191) if (len >= 191)
{ {

View File

@ -102,6 +102,17 @@ static cell_t CreateFakeClient(IPluginContext *pContext, const cell_t *params)
pContext->LocalToString(params[1], &netname); pContext->LocalToString(params[1], &netname);
#if SOURCE_ENGINE == SE_DOTA
int index;
engine->CreateFakeClient(&index, netname);
if (index == -1)
{
return 0;
}
return index;
#else
edict_t *pEdict = engine->CreateFakeClient(netname); edict_t *pEdict = engine->CreateFakeClient(netname);
/* :TODO: does the engine fire forwards for us and whatnot? no idea... */ /* :TODO: does the engine fire forwards for us and whatnot? no idea... */
@ -112,6 +123,7 @@ static cell_t CreateFakeClient(IPluginContext *pContext, const cell_t *params)
} }
return IndexOfEdict(pEdict); return IndexOfEdict(pEdict);
#endif
} }
static cell_t SetFakeClientConVar(IPluginContext *pContext, const cell_t *params) static cell_t SetFakeClientConVar(IPluginContext *pContext, const cell_t *params)
@ -138,7 +150,11 @@ static cell_t SetFakeClientConVar(IPluginContext *pContext, const cell_t *params
pContext->LocalToString(params[2], &cvar); pContext->LocalToString(params[2], &cvar);
pContext->LocalToString(params[3], &value); pContext->LocalToString(params[3], &value);
#if SOURCE_ENGINE == SE_DOTA
engine->SetFakeClientConVarValue(pPlayer->GetIndex(), cvar, value);
#else
engine->SetFakeClientConVarValue(pPlayer->GetEdict(), cvar, value); engine->SetFakeClientConVarValue(pPlayer->GetEdict(), cvar, value);
#endif
return 1; return 1;
} }

View File

@ -479,7 +479,7 @@ static cell_t GetClientUserId(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("Client %d is not connected", client); return pContext->ThrowNativeError("Client %d is not connected", client);
} }
return engine->GetPlayerUserId(pPlayer->GetEdict()); return GetPlayerUserId(pPlayer->GetEdict());
} }
static cell_t CanUserTarget(IPluginContext *pContext, const cell_t *params) static cell_t CanUserTarget(IPluginContext *pContext, const cell_t *params)
@ -1118,7 +1118,11 @@ static cell_t _ShowActivity(IPluginContext *pContext,
} }
UTIL_Format(message, sizeof(message), "%s%s\n", tag, buffer); UTIL_Format(message, sizeof(message), "%s%s\n", tag, buffer);
#if SOURCE_ENGINE == SE_DOTA
engine->ClientPrintf(pPlayer->GetIndex(), message);
#else
engine->ClientPrintf(pPlayer->GetEdict(), message); engine->ClientPrintf(pPlayer->GetEdict(), message);
#endif
display_in_chat = true; display_in_chat = true;
} }
} }

View File

@ -93,7 +93,9 @@ public: //IClientListner
public: // IVoiceServer public: // IVoiceServer
bool OnSetClientListening(int iReceiver, int iSender, bool bListen); bool OnSetClientListening(int iReceiver, int iSender, bool bListen);
void VoiceInit(); void VoiceInit();
#if SOURCE_ENGINE >= SE_ORANGEBOX #if SOURCE_ENGINE == SE_DOTA
void OnClientCommand(int client, const CCommand &args);
#elif SOURCE_ENGINE >= SE_ORANGEBOX
void OnClientCommand(edict_t *pEntity, const CCommand &args); void OnClientCommand(edict_t *pEntity, const CCommand &args);
#else #else
void OnClientCommand(edict_t *pEntity); void OnClientCommand(edict_t *pEntity);

View File

@ -217,7 +217,12 @@ int GetClientAimTarget(edict_t *pEdict, bool only_players)
QAngle eye_angles; QAngle eye_angles;
/* Get the private information we need */ /* Get the private information we need */
#if SOURCE_ENGINE == SE_DOTA
serverClients->ClientEarPosition(IndexOfEdict(pEdict), &eye_position);
#else
serverClients->ClientEarPosition(pEdict, &eye_position); serverClients->ClientEarPosition(pEdict, &eye_position);
#endif
if (!GetEyeAngles(pEntity, &eye_angles)) if (!GetEyeAngles(pEntity, &eye_angles))
{ {
return -2; return -2;

View File

@ -373,7 +373,11 @@ static cell_t SetClientViewEntity(IPluginContext *pContext, const cell_t *params
return pContext->ThrowNativeError("Entity %d is not valid", params[2]); return pContext->ThrowNativeError("Entity %d is not valid", params[2]);
} }
#if SOURCE_ENGINE == SE_DOTA
engine->SetView(params[1], params[2]);
#else
engine->SetView(player->GetEdict(), pEdict); engine->SetView(player->GetEdict(), pEdict);
#endif
return 1; return 1;
} }
@ -566,7 +570,7 @@ static cell_t SlapPlayer(IPluginContext *pContext, const cell_t *params)
if (should_slay) if (should_slay)
{ {
#if SOURCE_ENGINE == SE_DOTA #if SOURCE_ENGINE == SE_DOTA
engine->ClientCommand(pEdict, "kill\n"); engine->ClientCommand(params[1], "kill\n");
#else #else
pluginhelpers->ClientCommand(pEdict, "kill\n"); pluginhelpers->ClientCommand(pEdict, "kill\n");
#endif #endif
@ -593,7 +597,11 @@ static cell_t GetClientEyePosition(IPluginContext *pContext, const cell_t *param
} }
Vector pos; Vector pos;
#if SOURCE_ENGINE == SE_DOTA
serverClients->ClientEarPosition(params[1], &pos);
#else
serverClients->ClientEarPosition(player->GetEdict(), &pos); serverClients->ClientEarPosition(player->GetEdict(), &pos);
#endif
cell_t *addr; cell_t *addr;
pContext->LocalToPhysAddr(params[2], &addr); pContext->LocalToPhysAddr(params[2], &addr);

View File

@ -58,7 +58,9 @@ bool g_ClientMutes[65][65];
SH_DECL_HOOK3(IVoiceServer, SetClientListening, SH_NOATTRIB, 0, bool, int, int, bool); SH_DECL_HOOK3(IVoiceServer, SetClientListening, SH_NOATTRIB, 0, bool, int, int, bool);
#if SOURCE_ENGINE >= SE_ORANGEBOX #if SOURCE_ENGINE == SE_DOTA
SH_DECL_HOOK2_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, int, const CCommand &);
#elif SOURCE_ENGINE >= SE_ORANGEBOX
SH_DECL_HOOK2_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t *, const CCommand &); SH_DECL_HOOK2_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t *, const CCommand &);
#else #else
SH_DECL_HOOK1_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t *); SH_DECL_HOOK1_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t *);
@ -91,15 +93,19 @@ void SDKTools::VoiceInit()
SH_ADD_HOOK(IServerGameClients, ClientCommand, serverClients, SH_MEMBER(this, &SDKTools::OnClientCommand), true); SH_ADD_HOOK(IServerGameClients, ClientCommand, serverClients, SH_MEMBER(this, &SDKTools::OnClientCommand), true);
} }
#if SOURCE_ENGINE >= SE_ORANGEBOX #if SOURCE_ENGINE == SE_DOTA
void SDKTools::OnClientCommand(int client, const CCommand &args)
{
#elif SOURCE_ENGINE >= SE_ORANGEBOX
void SDKTools::OnClientCommand(edict_t *pEntity, const CCommand &args) void SDKTools::OnClientCommand(edict_t *pEntity, const CCommand &args)
{ {
int client = IndexOfEdict(pEntity);
#else #else
void SDKTools::OnClientCommand(edict_t *pEntity) void SDKTools::OnClientCommand(edict_t *pEntity)
{ {
CCommand args; CCommand args;
#endif
int client = IndexOfEdict(pEntity); int client = IndexOfEdict(pEntity);
#endif
if ((args.ArgC() > 1) && (stricmp(args.Arg(0), "vban") == 0)) if ((args.ArgC() > 1) && (stricmp(args.Arg(0), "vban") == 0))
{ {

View File

@ -521,7 +521,12 @@ static cell_t FadeClientVolume(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("Client index %d is not in game", client); return pContext->ThrowNativeError("Client index %d is not in game", client);
} }
engine->FadeClientVolume(player->GetEdict(), engine->FadeClientVolume(
#if SOURCE_ENGINE == SE_DOTA
player->GetIndex(),
#else
player->GetEdict(),
#endif
sp_ctof(params[2]), sp_ctof(params[2]),
sp_ctof(params[3]), sp_ctof(params[3]),
sp_ctof(params[4]), sp_ctof(params[4]),

View File

@ -41,7 +41,7 @@
#include <IAdminSystem.h> #include <IAdminSystem.h>
#define SMINTERFACE_PLAYERMANAGER_NAME "IPlayerManager" #define SMINTERFACE_PLAYERMANAGER_NAME "IPlayerManager"
#define SMINTERFACE_PLAYERMANAGER_VERSION 17 #define SMINTERFACE_PLAYERMANAGER_VERSION 18
struct edict_t; struct edict_t;
class IPlayerInfo; class IPlayerInfo;
@ -246,6 +246,13 @@ namespace SourceMod
* @return Steam account ID or 0 if not available. * @return Steam account ID or 0 if not available.
*/ */
virtual unsigned int GetSteamAccountID(bool validated = true) =0; virtual unsigned int GetSteamAccountID(bool validated = true) =0;
/**
* @brief Returns the client's edict/entity index.
*
* @return Client's index.
*/
virtual int GetIndex() const =0;
}; };
/** /**

View File

@ -154,4 +154,26 @@
} }
#endif //SOURCE_ENGINE >= SE_LEFT4DEAD #endif //SOURCE_ENGINE >= SE_LEFT4DEAD
#if SOURCE_ENGINE == SE_DOTA
inline int GetPlayerUserId(edict_t *pEdict)
{
return engine->GetPlayerUserId(IndexOfEdict(pEdict) - 1);
}
inline int GetPlayerUserId(int client)
{
engine->GetPlayerUserId(client - 1);
}
#else
inline int GetPlayerUserId(edict_t *pEdict)
{
return engine->GetPlayerUserId(pEdict);
}
inline int GetPlayerUserId(int client)
{
return engine->GetPlayerUserId(PEntityOfEntIndex(client));
}
#endif //SOURCE_ENGINE >= SE_DOTA
#endif //_INCLUDE_SOURCEMOD_COMPAT_WRAPPERS_H_ #endif //_INCLUDE_SOURCEMOD_COMPAT_WRAPPERS_H_