summaryrefslogtreecommitdiff
path: root/engine/event_system.h
blob: 0139cb459efce825ca22ecfdc686a0e4109ebafa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $Workfile:     $
// $Date:         $
//
//-----------------------------------------------------------------------------
// $Log: $
//
// $NoKeywords: $
//=============================================================================//
#if !defined( EVENT_SYSTEM_H )
#define EVENT_SYSTEM_H
#ifdef _WIN32
#pragma once
#endif

#include "event_flags.h"
#include "common.h"
#include "enginesingleuserfilter.h"


class SendTable;
class ClientClass;

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
class CEventInfo
{
public:
	enum
	{
		EVENT_INDEX_BITS = 8,
		EVENT_DATA_LEN_BITS = 11,
		MAX_EVENT_DATA = 192,  // ( 1<<8 bits == 256, but only using 192 below )
	};

	inline CEventInfo()
	{
		classID = 0;
		fire_delay = 0.0f;
		bits = 0;
		flags = 0;
		pSendTable = NULL;
		pClientClass = NULL;
		pData = NULL;
	}

	~CEventInfo()
	{
		if ( pData )
		{
			delete pData;
		}
	}

	CEventInfo( const CEventInfo& src )
	{
		classID = src.classID;
		fire_delay = src.fire_delay;
		bits = src.bits;
		flags = src.flags;
		pSendTable = src.pSendTable;
		pClientClass = src.pClientClass;
		filter.AddPlayersFromFilter( &src.filter );
				
		if ( src.pData )
		{
			int size = Bits2Bytes( src.bits );
			pData = new byte[size];
			Q_memcpy( pData, src.pData, size );
		}
		else
		{
			pData = NULL;
		}

	}

	// 0 implies not in use
	short classID;
	
	// If non-zero, the delay time when the event should be fired ( fixed up on the client )
	float fire_delay;

	// send table pointer or NULL if send as full update
	const SendTable *pSendTable;
	const ClientClass *pClientClass;
	
	// Length of data bits
	int		bits;
	// Raw event data
	byte	*pData;
	// CLIENT ONLY Reliable or not, etc.
	int		flags;
	
	// clients that see that event
	CEngineRecipientFilter filter;
};


#endif // EVENT_SYSTEM_H