implemented GetUserMessageName native
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40559
This commit is contained in:
parent
7ebe3f33cd
commit
3b207f2cc9
@ -19,6 +19,8 @@ CUserMessages g_UserMsgs;
|
|||||||
SH_DECL_HOOK2(IVEngineServer, UserMessageBegin, SH_NOATTRIB, 0, bf_write *, IRecipientFilter *, int);
|
SH_DECL_HOOK2(IVEngineServer, UserMessageBegin, SH_NOATTRIB, 0, bf_write *, IRecipientFilter *, int);
|
||||||
SH_DECL_HOOK0_void(IVEngineServer, MessageEnd, SH_NOATTRIB, 0);
|
SH_DECL_HOOK0_void(IVEngineServer, MessageEnd, SH_NOATTRIB, 0);
|
||||||
|
|
||||||
|
//:TODO: USE NEW MM IFACE TO SEARCH FOR MESSAGE NAMES ETC! faluco--> i'll do this when i have some spare time
|
||||||
|
|
||||||
CUserMessages::CUserMessages() : m_InterceptBuffer(m_pBase, 2500)
|
CUserMessages::CUserMessages() : m_InterceptBuffer(m_pBase, 2500)
|
||||||
{
|
{
|
||||||
m_Names = sm_trie_create();
|
m_Names = sm_trie_create();
|
||||||
@ -71,6 +73,13 @@ int CUserMessages::GetMessageIndex(const char *msg)
|
|||||||
return msgid;
|
return msgid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CUserMessages::GetMessageName(int msgid, char *buffer, size_t maxlen) const
|
||||||
|
{
|
||||||
|
int dummy;
|
||||||
|
|
||||||
|
return gamedll->GetUserMessageInfo(msgid, buffer, maxlen, dummy);
|
||||||
|
}
|
||||||
|
|
||||||
bf_write *CUserMessages::StartMessage(int msg_id, cell_t players[], unsigned int playersNum, int flags)
|
bf_write *CUserMessages::StartMessage(int msg_id, cell_t players[], unsigned int playersNum, int flags)
|
||||||
{
|
{
|
||||||
bf_write *buffer;
|
bf_write *buffer;
|
||||||
|
@ -40,6 +40,7 @@ public: //SMGlobalClass
|
|||||||
void OnSourceModAllShutdown();
|
void OnSourceModAllShutdown();
|
||||||
public: //IUserMessages
|
public: //IUserMessages
|
||||||
int GetMessageIndex(const char *msg);
|
int GetMessageIndex(const char *msg);
|
||||||
|
bool GetMessageName(int msgid, char *buffer, size_t maxlen) const;
|
||||||
bool HookUserMessage(int msg_id, IUserMessageListener *pListener, bool intercept=false);
|
bool HookUserMessage(int msg_id, IUserMessageListener *pListener, bool intercept=false);
|
||||||
bool UnhookUserMessage(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, cell_t players[], unsigned int playersNum, int flags);
|
||||||
|
@ -52,6 +52,7 @@ void UsrMessageNatives::OnSourceModShutdown()
|
|||||||
g_PluginSys.RemovePluginsListener(this);
|
g_PluginSys.RemovePluginsListener(this);
|
||||||
g_WrBitBufType = 0;
|
g_WrBitBufType = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UsrMessageNatives::OnHandleDestroy(HandleType_t type, void *object)
|
void UsrMessageNatives::OnHandleDestroy(HandleType_t type, void *object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -131,6 +132,7 @@ MsgListenerWrapper *UsrMessageNatives::FindListener(int msgid, IPluginContext *p
|
|||||||
|
|
||||||
return (found) ? listener : NULL;
|
return (found) ? listener : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UsrMessageNatives::RemoveListener(IPluginContext *pCtx, MsgListenerWrapper *listener, bool intercept)
|
bool UsrMessageNatives::RemoveListener(IPluginContext *pCtx, MsgListenerWrapper *listener, bool intercept)
|
||||||
{
|
{
|
||||||
List<MsgListenerWrapper *> *wrapper_list;
|
List<MsgListenerWrapper *> *wrapper_list;
|
||||||
@ -168,6 +170,21 @@ static cell_t smn_GetUserMessageId(IPluginContext *pCtx, const cell_t *params)
|
|||||||
return g_UserMsgs.GetMessageIndex(msgname);
|
return g_UserMsgs.GetMessageIndex(msgname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell_t smn_GetUserMessageName(IPluginContext *pCtx, const cell_t *params)
|
||||||
|
{
|
||||||
|
char *msgname;
|
||||||
|
|
||||||
|
pCtx->LocalToPhysAddr(params[2], (cell_t **)&msgname);
|
||||||
|
|
||||||
|
if (!g_UserMsgs.GetMessageName(params[1], msgname, params[3]))
|
||||||
|
{
|
||||||
|
msgname = "";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static cell_t smn_StartMessage(IPluginContext *pCtx, const cell_t *params)
|
static cell_t smn_StartMessage(IPluginContext *pCtx, const cell_t *params)
|
||||||
{
|
{
|
||||||
char *msgname;
|
char *msgname;
|
||||||
@ -269,6 +286,7 @@ static cell_t smn_HookUserMessage(IPluginContext *pCtx, const cell_t *params)
|
|||||||
intercept = (params[3]) ? true : false;
|
intercept = (params[3]) ? true : false;
|
||||||
listener = s_UsrMessageNatives.GetNewListener(pCtx);
|
listener = s_UsrMessageNatives.GetNewListener(pCtx);
|
||||||
listener->InitListener(msgid, pHook, pNotify, intercept);
|
listener->InitListener(msgid, pHook, pNotify, intercept);
|
||||||
|
|
||||||
g_UserMsgs.HookUserMessage(msgid, listener, intercept);
|
g_UserMsgs.HookUserMessage(msgid, listener, intercept);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -312,6 +330,7 @@ static cell_t smn_UnHookUserMessage(IPluginContext *pCtx, const cell_t *params)
|
|||||||
REGISTER_NATIVES(usrmsgnatives)
|
REGISTER_NATIVES(usrmsgnatives)
|
||||||
{
|
{
|
||||||
{"GetUserMessageId", smn_GetUserMessageId},
|
{"GetUserMessageId", smn_GetUserMessageId},
|
||||||
|
{"GetUserMessageName", smn_GetUserMessageName},
|
||||||
{"StartMessage", smn_StartMessage},
|
{"StartMessage", smn_StartMessage},
|
||||||
{"StartMessageEx", smn_StartMessageEx},
|
{"StartMessageEx", smn_StartMessageEx},
|
||||||
{"EndMessage", smn_EndMessage},
|
{"EndMessage", smn_EndMessage},
|
||||||
|
Loading…
Reference in New Issue
Block a user