summaryrefslogtreecommitdiff
path: root/engine/changeframelist.cpp
blob: 24695089557dcc0b2ce79588729b1414e2d23600 (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
105
106
107
108
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//

#include "basetypes.h"
#include "changeframelist.h"
#include "dt.h"
#include "utlvector.h"

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


class CChangeFrameList : public IChangeFrameList
{
public:

	void	Init( int nProperties, int iCurTick )
	{
		m_ChangeTicks.SetSize( nProperties );
		for ( int i=0; i < nProperties; i++ )
			m_ChangeTicks[i] = iCurTick;
	}


// IChangeFrameList implementation.
public:

	virtual void	Release()
	{
		delete this;
	}

	virtual IChangeFrameList* Copy()
	{
		CChangeFrameList *pRet = new CChangeFrameList;

		int numProps = m_ChangeTicks.Count();

		pRet->m_ChangeTicks.SetSize( numProps );

		for ( int i=0; i < numProps; i++ )
		{
			pRet->m_ChangeTicks[ i ] = m_ChangeTicks[ i ];
		}

		return pRet;

	}

	virtual int		GetNumProps()
	{
		return m_ChangeTicks.Count();
	}

	virtual void	SetChangeTick( const int *pPropIndices, int nPropIndices, const int iTick )
	{
		for ( int i=0; i < nPropIndices; i++ )
		{
			m_ChangeTicks[ pPropIndices[i] ] = iTick;
		}
	}

	virtual int		GetPropsChangedAfterTick( int iTick, int *iOutProps, int nMaxOutProps )
	{
		int nOutProps = 0;

		int c = m_ChangeTicks.Count();
		
		Assert( c <= nMaxOutProps );

		for ( int i=0; i < c; i++ )
		{
			if ( m_ChangeTicks[i] > iTick )
			{
				iOutProps[nOutProps] = i;
				++nOutProps;
			}
		}

		return nOutProps;
	}

// IChangeFrameList implementation.
protected:

	virtual			~CChangeFrameList()
	{
	}

private:
	// Change frames for each property.
	CUtlVector<int>		m_ChangeTicks;
};


IChangeFrameList* AllocChangeFrameList( int nProperties, int iCurTick )
{
	CChangeFrameList *pRet = new CChangeFrameList;
	pRet->Init( nProperties, iCurTick);
	return pRet;
}