summaryrefslogtreecommitdiff
path: root/game/shared/econ/econ_contribution.cpp
blob: 25dc060461d43cd9d52fb6a400501838a0418c16 (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Code for the CTFMapContribution object
//
// $NoKeywords: $
//=============================================================================//

#include "cbase.h"

#include "econ_contribution.h"

using namespace GCSDK;

#ifdef GC
IMPLEMENT_CLASS_MEMPOOL( CTFMapContribution, 10 * 1000, UTLMEMORYPOOL_GROW_SLOW );

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

bool CTFMapContribution::BYieldingAddInsertToTransaction( GCSDK::CSQLAccess & sqlAccess )
{
	CSchMapContribution schMapContribution;
	WriteToRecord( &schMapContribution );
	return CSchemaSharedObjectHelper::BYieldingAddInsertToTransaction( sqlAccess, &schMapContribution );
}

bool CTFMapContribution::BYieldingAddWriteToTransaction( GCSDK::CSQLAccess & sqlAccess, const CUtlVector< int > &fields )
{
	CSchMapContribution schMapContribution;
	WriteToRecord( &schMapContribution );
	CColumnSet csDatabaseDirty( schMapContribution.GetPSchema()->GetRecordInfo() );
	csDatabaseDirty.MakeEmpty();
	if ( fields.HasElement( CSOTFMapContribution::kContributionLevelFieldNumber ) )
	{
		csDatabaseDirty.BAddColumn( CSchMapContribution::k_iField_unContributionLevel );
	}
	return CSchemaSharedObjectHelper::BYieldingAddWriteToTransaction( sqlAccess, &schMapContribution, csDatabaseDirty );
}

bool CTFMapContribution::BYieldingAddRemoveToTransaction( GCSDK::CSQLAccess & sqlAccess )
{
	CSchMapContribution schMapContribution;
	WriteToRecord( &schMapContribution );
	return CSchemaSharedObjectHelper::BYieldingAddRemoveToTransaction( sqlAccess, &schMapContribution );
}

void CTFMapContribution::WriteToRecord( CSchMapContribution *pMapContribution ) const
{
	pMapContribution->m_unAccountID = Obj().account_id();
	pMapContribution->m_unDefIndex = Obj().def_index();
	pMapContribution->m_unContributionLevel = Obj().contribution_level();
}


void CTFMapContribution::ReadFromRecord( const CSchMapContribution & mapContribution )
{
	Obj().set_account_id( mapContribution.m_unAccountID );
	Obj().set_def_index( mapContribution.m_unDefIndex );
	Obj().set_contribution_level( mapContribution.m_unContributionLevel );
}



#endif