blob: 329a86a194d9f8cc9be7ce396521f9fbd71e324a (
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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================
#ifndef ECON_ITEM_SYSTEM_H
#define ECON_ITEM_SYSTEM_H
#ifdef _WIN32
#pragma once
#endif
#include "econ_item_view.h"
#include "game_item_schema.h"
//==================================================================================
// ITEM SYSTEM
//==================================================================================
#define GC_MOTD_CACHE_FILE "cfg/motd_entries.txt"
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
class CEconItemSystem
{
public:
CEconItemSystem( void );
virtual ~CEconItemSystem( void );
// Setup & parse in the item data files.
void Init( void );
void Shutdown( void );
// Return the static item data for the specified item index
GameItemDefinition_t *GetStaticDataForItemByDefIndex( item_definition_index_t iItemDefIndex )
{
return (GameItemDefinition_t *)m_itemSchema.GetItemDefinition( iItemDefIndex );
}
CEconItemDefinition *GetStaticDataForItemByName( const char *pszDefName )
{
return m_itemSchema.GetItemDefinitionByName( pszDefName );
}
CEconItemAttributeDefinition *GetStaticDataForAttributeByDefIndex( attrib_definition_index_t iAttribDefinitionIndex )
{
return m_itemSchema.GetAttributeDefinition( iAttribDefinitionIndex );
}
CEconItemAttributeDefinition *GetStaticDataForAttributeByName( const char *pszDefName )
{
return m_itemSchema.GetAttributeDefinitionByName( pszDefName );
}
// Select and return a random item's definition index matching the specified criteria
item_definition_index_t GenerateRandomItem( CItemSelectionCriteria *pCriteria, entityquality_t *outEntityQuality );
// Select and return the base item definition index for a class's load-out slot
// Note: baseitemcriteria_t is game-specific and/or may not exist!
virtual item_definition_index_t GenerateBaseItem( struct baseitemcriteria_t *pCriteria ) { return INVALID_ITEM_DEF_INDEX; }
// Return a random item quality
entityquality_t GetRandomQualityForItem( bool bPreventUnique = false );
// Decrypt the item files and return the keyvalue
bool DecryptItemFiles( KeyValues *pKV, const char *pName );
GameItemSchema_t *GetItemSchema() { return &m_itemSchema; }
// Open the server's whitelist, and if it exists, set the appropriate items allowed.
void ReloadWhitelist( void );
void ResetAttribStringCache( void );
protected:
// Read the specified item schema file. Init the item schema with the contents
void ParseItemSchemaFile( const char *pFilename );
// Key to decrypt the item description files
const unsigned char *GetEncryptionKey( void ) { return (unsigned char *)"A5fSXbf7"; }
private:
GameItemSchema_t m_itemSchema;
};
CEconItemSystem *ItemSystem( void );
#endif // ECON_ITEM_SYSTEM_H
|