From f950225229737a090ea1a0b8bc90914342472c6e Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 17 Nov 2007 05:33:47 +0000 Subject: [PATCH] added GetGlobalTarget/SetGlobalTarget to g_pSM const'd some things --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401696 --- core/CellRecipientFilter.h | 4 ++-- core/HalfLife2.cpp | 7 ++++++- core/UserMessages.cpp | 2 +- core/UserMessages.h | 2 +- core/sourcemod.cpp | 4 +++- core/sourcemod.h | 2 +- public/ISourceMod.h | 19 ++++++++++++++++++- public/IUserMessages.h | 2 +- 8 files changed, 33 insertions(+), 9 deletions(-) diff --git a/core/CellRecipientFilter.h b/core/CellRecipientFilter.h index b3a5a1f9..30070553 100644 --- a/core/CellRecipientFilter.h +++ b/core/CellRecipientFilter.h @@ -46,7 +46,7 @@ public: //IRecipientFilter int GetRecipientCount() const; int GetRecipientIndex(int slot) const; public: - void Initialize(cell_t *ptr, size_t count); + void Initialize(const cell_t *ptr, size_t count); void SetToReliable(bool isreliable); void SetToInit(bool isinitmsg); void Reset(); @@ -98,7 +98,7 @@ inline void CellRecipientFilter::SetToReliable(bool isreliable) m_IsReliable = isreliable; } -inline void CellRecipientFilter::Initialize(cell_t *ptr, size_t count) +inline void CellRecipientFilter::Initialize(const cell_t *ptr, size_t count) { memcpy(m_Players, ptr, count * sizeof(cell_t)); m_Size = count; diff --git a/core/HalfLife2.cpp b/core/HalfLife2.cpp index 993a0e98..6aec953e 100644 --- a/core/HalfLife2.cpp +++ b/core/HalfLife2.cpp @@ -35,6 +35,7 @@ #include "UserMessages.h" #include "PlayerManager.h" #include "sm_stringutil.h" +#include "GameConfigs.h" #include CHalfLife2 g_HL2; @@ -308,7 +309,11 @@ bool CHalfLife2::HintTextMsg(int client, const char *msg) return false; } - pBitBuf->WriteByte(1); + const char *pre_byte = g_pGameConf->GetKeyValue("HintTextPreByte"); + if (pre_byte != NULL && strcmp(pre_byte, "yes") == 0) + { + pBitBuf->WriteByte(1); + } pBitBuf->WriteString(msg); g_UserMsgs.EndMessage(); diff --git a/core/UserMessages.cpp b/core/UserMessages.cpp index 7384b741..0413286f 100644 --- a/core/UserMessages.cpp +++ b/core/UserMessages.cpp @@ -135,7 +135,7 @@ bool UserMessages::GetMessageName(int msgid, char *buffer, size_t maxlength) con return false; } -bf_write *UserMessages::StartMessage(int msg_id, cell_t players[], unsigned int playersNum, int flags) +bf_write *UserMessages::StartMessage(int msg_id, const cell_t players[], unsigned int playersNum, int flags) { bf_write *buffer; diff --git a/core/UserMessages.h b/core/UserMessages.h index 9736b0fc..01969fcf 100644 --- a/core/UserMessages.h +++ b/core/UserMessages.h @@ -69,7 +69,7 @@ public: //IUserMessages bool GetMessageName(int msgid, char *buffer, size_t maxlength) const; bool HookUserMessage(int msg_id, IUserMessageListener *pListener, bool intercept=false); bool UnhookUserMessage(int msg_id, IUserMessageListener *pListener, bool intercept=false); - bf_write *StartMessage(int msg_id, cell_t players[], unsigned int playersNum, int flags); + bf_write *StartMessage(int msg_id, const cell_t players[], unsigned int playersNum, int flags); bool EndMessage(); public: bf_write *OnStartMessage_Pre(IRecipientFilter *filter, int msg_type); diff --git a/core/sourcemod.cpp b/core/sourcemod.cpp index e59afd31..e94ed402 100644 --- a/core/sourcemod.cpp +++ b/core/sourcemod.cpp @@ -586,9 +586,11 @@ const char *SourceModBase::GetGamePath() const return g_BaseDir.c_str(); } -void SourceModBase::SetGlobalTarget(unsigned int index) +unsigned int SourceModBase::SetGlobalTarget(unsigned int index) { + unsigned int old = m_target; m_target = index; + return old; } unsigned int SourceModBase::GetGlobalTarget() const diff --git a/core/sourcemod.h b/core/sourcemod.h index 9a804a43..1b222c80 100644 --- a/core/sourcemod.h +++ b/core/sourcemod.h @@ -83,7 +83,7 @@ public: /** * @brief Stores the global target index. */ - void SetGlobalTarget(unsigned int index); + unsigned int SetGlobalTarget(unsigned int index); /** * @brief Returns the global target index. diff --git a/public/ISourceMod.h b/public/ISourceMod.h index bddc33c4..af39d30b 100644 --- a/public/ISourceMod.h +++ b/public/ISourceMod.h @@ -43,7 +43,7 @@ #include #define SMINTERFACE_SOURCEMOD_NAME "ISourceMod" -#define SMINTERFACE_SOURCEMOD_VERSION 3 +#define SMINTERFACE_SOURCEMOD_VERSION 4 /** * @brief Forward declaration of the KeyValues class. @@ -199,6 +199,23 @@ namespace SourceMod * @return Adjusted server time. */ virtual time_t GetAdjustedTime() =0; + + /** + * @brief Sets the global client SourceMod will use for assisted + * translations (that is, %t). + * + * @param index Client index. + * @return Old global client value. + */ + virtual unsigned int SetGlobalTarget(unsigned int index) =0; + + /** + * @brief Returns the global client SourceMod is currently using + * for assisted translations (that is, %t). + * + * @return Global client value. + */ + virtual unsigned int GetGlobalTarget() const =0; }; } diff --git a/public/IUserMessages.h b/public/IUserMessages.h index 4603643a..c5524b1d 100644 --- a/public/IUserMessages.h +++ b/public/IUserMessages.h @@ -144,7 +144,7 @@ namespace SourceMod * @param flags Flags to use for sending the message. * @return bf_write structure to write message with, or NULL on failure. */ - virtual bf_write *StartMessage(int msg_id, cell_t players[], unsigned int playersNum, int flags) =0; + virtual bf_write *StartMessage(int msg_id, const cell_t players[], unsigned int playersNum, int flags) =0; /** * @brief Wrapper around UserMessageEnd for use with StartMessage().