Wrap ClientPrintf into IGamePlayer (bug 6021, r=asherkin).

This commit is contained in:
Kyle Sanderson 2014-01-29 21:41:41 -07:00
parent b0ee5ce485
commit af7b8cd9a3
6 changed files with 48 additions and 44 deletions

View File

@ -413,10 +413,12 @@ bool ConCmdManager::CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmi
return true;
}
#if SOURCE_ENGINE != SE_DOTA
edict_t *pEdict = PEntityOfEntIndex(client);
#endif
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
if (!pPlayer)
{
return false;
}
/* If we got here, the command failed... */
char buffer[128];
if (!logicore.CoreTranslate(buffer, sizeof(buffer), "%T", 2, NULL, "No Access", &client))
@ -429,11 +431,7 @@ bool ConCmdManager::CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmi
{
char fullbuffer[192];
UTIL_Format(fullbuffer, sizeof(fullbuffer), "[SM] %s.\n", buffer);
#if SOURCE_ENGINE == SE_DOTA
engine->ClientPrintf(client, fullbuffer);
#else
engine->ClientPrintf(pEdict, fullbuffer);
#endif
pPlayer->PrintToConsole(fullbuffer);
}
else if (replyto == SM_REPLY_CHAT)
{

View File

@ -843,11 +843,13 @@ void ClientConsolePrint(edict_t *e, const char *fmt, ...)
buffer[len] = '\0';
}
#if SOURCE_ENGINE == SE_DOTA
engine->ClientPrintf(CEntityIndex(IndexOfEdict(e)), buffer);
#else
engine->ClientPrintf(e, buffer);
#endif
CPlayer *pPlayer = g_Players.GetPlayerByIndex(IndexOfEdict(e));
if (!pPlayer)
{
return;
}
pPlayer->PrintToConsole(buffer);
}
void ListExtensionsToClient(CPlayer *player, const CCommand &args)
@ -2323,3 +2325,23 @@ unsigned int CPlayer::GetSerial()
{
return m_Serial.value;
}
void CPlayer::PrintToConsole(const char *pMsg)
{
if (m_IsConnected == false || m_bFakeClient == true)
{
return;
}
INetChannel *pNetChan = static_cast<INetChannel *>(engine->GetPlayerNetInfo(m_iIndex));
if (pNetChan == NULL)
{
return;
}
#if SOURCE_ENGINE == SE_DOTA
engine->ClientPrintf(m_iIndex, pMsg);
#else
engine->ClientPrintf(m_pEdict, pMsg);
#endif
}

View File

@ -91,6 +91,7 @@ public:
void NotifyPostAdminChecks();
unsigned int GetSerial();
int GetIndex() const;
void PrintToConsole(const char *pMsg);
public:
void DoBasicAdminChecks();
void MarkAsBeingKicked();

View File

@ -884,11 +884,7 @@ static cell_t sm_PrintToConsole(IPluginContext *pCtx, const cell_t *params)
if (index != 0)
{
#if SOURCE_ENGINE == SE_DOTA
engine->ClientPrintf(pPlayer->GetIndex(), buffer);
#else
engine->ClientPrintf(pPlayer->GetEdict(), buffer);
#endif
pPlayer->PrintToConsole(buffer);
} else {
META_CONPRINT(buffer);
}
@ -1200,11 +1196,7 @@ static cell_t ReplyToCommand(IPluginContext *pContext, const cell_t *params)
{
buffer[len++] = '\n';
buffer[len] = '\0';
#if SOURCE_ENGINE == SE_DOTA
engine->ClientPrintf(pPlayer->GetIndex(), buffer);
#else
engine->ClientPrintf(pPlayer->GetEdict(), buffer);
#endif
pPlayer->PrintToConsole(buffer);
} else if (replyto == SM_REPLY_CHAT) {
if (len >= 191)
{

View File

@ -1118,11 +1118,7 @@ static cell_t _ShowActivity(IPluginContext *pContext,
}
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);
#endif
pPlayer->PrintToConsole(message);
display_in_chat = true;
}
}
@ -1248,20 +1244,8 @@ static cell_t _ShowActivity2(IPluginContext *pContext,
* simply gets added to the console, so we don't want it to print
* twice.
*/
if (replyto == SM_REPLY_CONSOLE)
{
#if 0
UTIL_Format(message, sizeof(message), "%s%s\n", tag, buffer);
engine->ClientPrintf(pPlayer->GetEdict(), message);
#endif
UTIL_Format(message, sizeof(message), "%s%s", tag, buffer);
g_HL2.TextMsg(client, HUD_PRINTTALK, message);
}
else
{
UTIL_Format(message, sizeof(message), "%s%s", tag, buffer);
g_HL2.TextMsg(client, HUD_PRINTTALK, message);
}
UTIL_Format(message, sizeof(message), "%s%s", tag, buffer);
g_HL2.TextMsg(client, HUD_PRINTTALK, message);
}
else
{

View File

@ -41,7 +41,7 @@
#include <IAdminSystem.h>
#define SMINTERFACE_PLAYERMANAGER_NAME "IPlayerManager"
#define SMINTERFACE_PLAYERMANAGER_VERSION 18
#define SMINTERFACE_PLAYERMANAGER_VERSION 19
struct edict_t;
class IPlayerInfo;
@ -253,6 +253,13 @@ namespace SourceMod
* @return Client's index.
*/
virtual int GetIndex() const =0;
/**
* @brief Prints a string to the client console.
*
* @param pMsg String to print.
*/
virtual void PrintToConsole(const char *pMsg) =0;
};
/**