aboutsummaryrefslogtreecommitdiff
path: root/sp/src/game/server/base_transmit_proxy.cpp
blob: 4832af8df942fc1259e80c38027f6a65ae255cca (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
//=============================================================================//

#include "cbase.h"
#include "base_transmit_proxy.h"

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

CBaseTransmitProxy::CBaseTransmitProxy( CBaseEntity *pEnt )
{
	m_hEnt = pEnt;
	m_refCount = 0;
}


CBaseTransmitProxy::~CBaseTransmitProxy()
{
	// Unlink from our parent entity.
	if ( m_hEnt )
	{
		m_refCount = 0xFFFF; // Prevent us from deleting ourselves again.
		// m_hEnt->NetworkProp()->SetTransmitProxy( NULL );
	}
}


int CBaseTransmitProxy::ShouldTransmit( const CCheckTransmitInfo *pInfo, int nPrevShouldTransmitResult )
{
	// Anyone implementing a transmit proxy should override this since that's the point!!
	Assert( false );
	return FL_EDICT_DONTSEND;
}


void CBaseTransmitProxy::AddRef()
{
	m_refCount++;
}


void CBaseTransmitProxy::Release()
{
	if ( m_refCount == 0xFFFF )
	{
		// This means we are inside our destructor already, so we don't want to do anything here.
	}
	else if ( m_refCount <= 1 )
	{
		delete this;
	}
	else
	{
		--m_refCount;
	}
}