- changed TextMsg to return a bool
- fixed a bug where you couldn't send messages from post hooks - added protection in functions which expect StartMessage to succeed --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401138
This commit is contained in:
parent
0069612c95
commit
3fdc205544
@ -244,13 +244,19 @@ void CHalfLife2::SetEdictStateChanged(edict_t *pEdict, unsigned short offset)
|
||||
}
|
||||
}
|
||||
|
||||
void CHalfLife2::TextMsg(int client, int dest, const char *msg)
|
||||
bool CHalfLife2::TextMsg(int client, int dest, const char *msg)
|
||||
{
|
||||
bf_write *pBitBuf = NULL;
|
||||
cell_t players[] = {client};
|
||||
|
||||
pBitBuf = g_UserMsgs.StartMessage(m_MsgTextMsg, players, 1, USERMSG_RELIABLE);
|
||||
if ((pBitBuf = g_UserMsgs.StartMessage(m_MsgTextMsg, players, 1, USERMSG_RELIABLE)) == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
pBitBuf->WriteByte(dest);
|
||||
pBitBuf->WriteString(msg);
|
||||
g_UserMsgs.EndMessage();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public: //IGameHelpers
|
||||
ServerClass *FindServerClass(const char *classname);
|
||||
typedescription_t *FindInDataMap(datamap_t *pMap, const char *offset);
|
||||
void SetEdictStateChanged(edict_t *pEdict, unsigned short offset);
|
||||
void TextMsg(int client, int dest, const char *msg);
|
||||
bool TextMsg(int client, int dest, const char *msg);
|
||||
private:
|
||||
DataTableInfo *_FindServerClass(const char *classname);
|
||||
private:
|
||||
|
@ -330,6 +330,8 @@ void UserMessages::OnMessageEnd_Post()
|
||||
iter++;
|
||||
}
|
||||
|
||||
m_InHook = false;
|
||||
|
||||
pList = &m_msgHooks[m_CurId];
|
||||
for (iter=pList->begin(); iter!=pList->end(); )
|
||||
{
|
||||
@ -348,8 +350,6 @@ void UserMessages::OnMessageEnd_Post()
|
||||
pInfo->IsHooked = false;
|
||||
iter++;
|
||||
}
|
||||
|
||||
m_InHook = false;
|
||||
}
|
||||
|
||||
void UserMessages::OnMessageEnd_Pre()
|
||||
|
@ -284,7 +284,10 @@ static cell_t PrintToChat(IPluginContext *pContext, const cell_t *params)
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_HL2.TextMsg(client, HUD_PRINTTALK, buffer);
|
||||
if (!g_HL2.TextMsg(client, HUD_PRINTTALK, buffer))
|
||||
{
|
||||
return pContext->ThrowNativeError("Could not send a usermessage");
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -315,7 +318,10 @@ static cell_t PrintCenterText(IPluginContext *pContext, const cell_t *params)
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_HL2.TextMsg(client, HUD_PRINTCENTER, buffer);
|
||||
if (!g_HL2.TextMsg(client, HUD_PRINTCENTER, buffer))
|
||||
{
|
||||
return pContext->ThrowNativeError("Could not send a usermessage");
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -95,8 +95,9 @@ namespace SourceMod
|
||||
* @param client Client index.
|
||||
* @param dest Destination on the HUD.
|
||||
* @param msg Message to send.
|
||||
* @return True on success, false on failure.
|
||||
*/
|
||||
virtual void TextMsg(int client, int dest, const char *msg) =0;
|
||||
virtual bool TextMsg(int client, int dest, const char *msg) =0;
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user