Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef ECON_ITEM_SYSTEM_H
  7. #define ECON_ITEM_SYSTEM_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "econ_item_view.h"
  12. #include "game_item_schema.h"
  13. //==================================================================================
  14. // ITEM SYSTEM
  15. //==================================================================================
  16. #define GC_MOTD_CACHE_FILE "cfg/motd_entries.txt"
  17. //-----------------------------------------------------------------------------
  18. // Purpose:
  19. //-----------------------------------------------------------------------------
  20. class CEconItemSystem
  21. {
  22. public:
  23. CEconItemSystem( void );
  24. virtual ~CEconItemSystem( void );
  25. // Setup & parse in the item data files.
  26. void Init( void );
  27. void Shutdown( void );
  28. // Return the static item data for the specified item index
  29. GameItemDefinition_t *GetStaticDataForItemByDefIndex( item_definition_index_t iItemDefIndex )
  30. {
  31. return (GameItemDefinition_t *)m_itemSchema.GetItemDefinition( iItemDefIndex );
  32. }
  33. CEconItemDefinition *GetStaticDataForItemByName( const char *pszDefName )
  34. {
  35. return m_itemSchema.GetItemDefinitionByName( pszDefName );
  36. }
  37. CEconItemAttributeDefinition *GetStaticDataForAttributeByDefIndex( attrib_definition_index_t iAttribDefinitionIndex )
  38. {
  39. return m_itemSchema.GetAttributeDefinition( iAttribDefinitionIndex );
  40. }
  41. CEconItemAttributeDefinition *GetStaticDataForAttributeByName( const char *pszDefName )
  42. {
  43. return m_itemSchema.GetAttributeDefinitionByName( pszDefName );
  44. }
  45. // Select and return a random item's definition index matching the specified criteria
  46. item_definition_index_t GenerateRandomItem( CItemSelectionCriteria *pCriteria, entityquality_t *outEntityQuality );
  47. // Select and return the base item definition index for a class's load-out slot
  48. // Note: baseitemcriteria_t is game-specific and/or may not exist!
  49. virtual item_definition_index_t GenerateBaseItem( struct baseitemcriteria_t *pCriteria ) { return INVALID_ITEM_DEF_INDEX; }
  50. // Return a random item quality
  51. entityquality_t GetRandomQualityForItem( bool bPreventUnique = false );
  52. // Decrypt the item files and return the keyvalue
  53. bool DecryptItemFiles( KeyValues *pKV, const char *pName );
  54. GameItemSchema_t *GetItemSchema() { return &m_itemSchema; }
  55. // Open the server's whitelist, and if it exists, set the appropriate items allowed.
  56. void ReloadWhitelist( void );
  57. void ResetAttribStringCache( void );
  58. protected:
  59. // Read the specified item schema file. Init the item schema with the contents
  60. void ParseItemSchemaFile( const char *pFilename );
  61. // Key to decrypt the item description files
  62. const unsigned char *GetEncryptionKey( void ) { return (unsigned char *)"A5fSXbf7"; }
  63. private:
  64. GameItemSchema_t m_itemSchema;
  65. };
  66. CEconItemSystem *ItemSystem( void );
  67. #endif // ECON_ITEM_SYSTEM_H