diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/shared/econ/econ_item_system.h | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'game/shared/econ/econ_item_system.h')
| -rw-r--r-- | game/shared/econ/econ_item_system.h | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/game/shared/econ/econ_item_system.h b/game/shared/econ/econ_item_system.h new file mode 100644 index 0000000..329a86a --- /dev/null +++ b/game/shared/econ/econ_item_system.h @@ -0,0 +1,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 |