2007-03-01 23:49:08 +01:00
|
|
|
/**
|
2007-03-22 22:50:20 +01:00
|
|
|
* vim: set ts=4 :
|
2007-08-01 04:12:47 +02:00
|
|
|
* ================================================================
|
|
|
|
* SourceMod
|
|
|
|
* Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
|
|
|
|
* ================================================================
|
2007-03-22 22:50:20 +01:00
|
|
|
*
|
2007-08-01 04:12:47 +02:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License,
|
|
|
|
* version 3.0, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* As a special exception, AlliedModders LLC gives you permission to
|
|
|
|
* link the code of this program (as well as its derivative works) to
|
|
|
|
* "Half-Life 2," the "Source Engine," the "SourcePawn JIT," and any
|
|
|
|
* Game MODs that run on software by the Valve Corporation. You must
|
|
|
|
* obey the GNU General Public License in all respects for all other
|
|
|
|
* code used. Additionally, AlliedModders LLC grants this exception
|
|
|
|
* to all derivative works. AlliedModders LLC defines further
|
|
|
|
* exceptions, found in LICENSE.txt (as of this writing, version
|
|
|
|
* JULY-31-2007), or <http://www.sourcemod.net/license.php>.
|
2007-03-22 22:50:20 +01:00
|
|
|
*
|
|
|
|
* Version: $Id$
|
|
|
|
*/
|
2007-03-01 23:49:08 +01:00
|
|
|
|
|
|
|
#ifndef _INCLUDE_SOURCEMOD_CUSERMESSAGES_H_
|
|
|
|
#define _INCLUDE_SOURCEMOD_CUSERMESSAGES_H_
|
|
|
|
|
2007-03-03 01:56:01 +01:00
|
|
|
#include "ShareSys.h"
|
2007-03-01 23:49:08 +01:00
|
|
|
#include <IUserMessages.h>
|
|
|
|
#include "sourcemm_api.h"
|
|
|
|
#include "sm_trie.h"
|
|
|
|
#include "CellRecipientFilter.h"
|
|
|
|
|
|
|
|
using namespace SourceHook;
|
|
|
|
using namespace SourceMod;
|
|
|
|
|
|
|
|
#define INVALID_MESSAGE_ID -1
|
|
|
|
|
2007-03-11 04:04:39 +01:00
|
|
|
struct ListenerInfo
|
|
|
|
{
|
|
|
|
IUserMessageListener *Callback;
|
|
|
|
bool IsHooked;
|
|
|
|
bool KillMe;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef List<ListenerInfo *> MsgList;
|
|
|
|
typedef List<ListenerInfo *>::iterator MsgIter;
|
2007-03-01 23:49:08 +01:00
|
|
|
|
2007-03-15 05:45:17 +01:00
|
|
|
class UserMessages :
|
2007-03-01 23:49:08 +01:00
|
|
|
public IUserMessages,
|
|
|
|
public SMGlobalClass
|
|
|
|
{
|
|
|
|
public:
|
2007-03-15 05:45:17 +01:00
|
|
|
UserMessages();
|
|
|
|
~UserMessages();
|
2007-03-01 23:49:08 +01:00
|
|
|
public: //SMGlobalClass
|
2007-05-12 06:47:58 +02:00
|
|
|
void OnSourceModStartup(bool late);
|
2007-03-03 01:56:01 +01:00
|
|
|
void OnSourceModAllInitialized();
|
2007-03-01 23:49:08 +01:00
|
|
|
void OnSourceModAllShutdown();
|
|
|
|
public: //IUserMessages
|
|
|
|
int GetMessageIndex(const char *msg);
|
2007-05-12 06:47:58 +02:00
|
|
|
bool GetMessageName(int msgid, char *buffer, size_t maxlength) const;
|
2007-03-01 23:49:08 +01:00
|
|
|
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);
|
|
|
|
bool EndMessage();
|
|
|
|
public:
|
|
|
|
bf_write *OnStartMessage_Pre(IRecipientFilter *filter, int msg_type);
|
|
|
|
bf_write *OnStartMessage_Post(IRecipientFilter *filter, int msg_type);
|
|
|
|
void OnMessageEnd_Pre();
|
|
|
|
void OnMessageEnd_Post();
|
|
|
|
private:
|
2007-03-11 04:04:39 +01:00
|
|
|
void _DecRefCounter();
|
|
|
|
private:
|
|
|
|
List<ListenerInfo *> m_msgHooks[255];
|
|
|
|
List<ListenerInfo *> m_msgIntercepts[255];
|
|
|
|
CStack<ListenerInfo *> m_FreeListeners;
|
2007-03-01 23:49:08 +01:00
|
|
|
unsigned char m_pBase[2500];
|
|
|
|
IRecipientFilter *m_CurRecFilter;
|
|
|
|
bf_write m_InterceptBuffer;
|
|
|
|
bf_write *m_OrigBuffer;
|
|
|
|
bf_read m_ReadBuffer;
|
|
|
|
size_t m_HookCount;
|
|
|
|
bool m_InHook;
|
2007-03-11 20:26:47 +01:00
|
|
|
bool m_BlockEndPost;
|
2007-05-12 06:47:58 +02:00
|
|
|
bool m_FallbackSearch;
|
2007-03-01 23:49:08 +01:00
|
|
|
|
|
|
|
Trie *m_Names;
|
|
|
|
CellRecipientFilter m_CellRecFilter;
|
|
|
|
bool m_InExec;
|
|
|
|
int m_CurFlags;
|
|
|
|
int m_CurId;
|
|
|
|
};
|
|
|
|
|
2007-03-15 05:45:17 +01:00
|
|
|
extern UserMessages g_UserMsgs;
|
2007-03-01 23:49:08 +01:00
|
|
|
|
|
|
|
#endif //_INCLUDE_SOURCEMOD_CUSERMESSAGES_H_
|