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.

102 lines
3.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //===================================================================
  4. #ifndef ECONITEMPRESET_H
  5. #define ECONITEMPRESET_H
  6. #ifdef _WIN32
  7. #pragma once
  8. #endif
  9. #include "gcsdk/protobufsharedobject.h"
  10. #include "gcsdk/gcclientsdk.h"
  11. #include "base_gcmessages.pb.h"
  12. #include "econ/econ_item_constants.h"
  13. namespace GCSDK
  14. {
  15. class CSQLAccess;
  16. };
  17. class CSOClassPresetClientData;
  18. typedef uint8 equipped_preset_t;
  19. struct PresetSlotItem_t
  20. {
  21. #ifdef GC_DLL
  22. DECLARE_CLASS_MEMPOOL( PresetSlotItem_t );
  23. #endif
  24. equipped_slot_t m_unSlotID;
  25. itemid_t m_ulItemOriginalID; // Original ID of the item in this slot. We store this instead of the current ID to avoid breaking presets when items get renamed, etc.
  26. };
  27. // --------------------------------------------------------------------------
  28. // Purpose:
  29. // --------------------------------------------------------------------------
  30. class CEconItemPerClassPresetData : public GCSDK::CSharedObject
  31. {
  32. #ifdef GC_DLL
  33. DECLARE_CLASS_MEMPOOL( CEconItemPerClassPresetData );
  34. #endif
  35. public:
  36. typedef GCSDK::CSharedObject BaseClass;
  37. const static int k_nTypeID = k_EEconTypeItemPresetInstance;
  38. virtual int GetTypeID() const OVERRIDE { return k_nTypeID; }
  39. CEconItemPerClassPresetData();
  40. CEconItemPerClassPresetData( uint32 unAccountID, equipped_class_t unClassID );
  41. virtual bool BIsKeyLess( const CSharedObject& soRHS ) const;
  42. #ifdef GC
  43. virtual bool BYieldingAddInsertToTransaction( GCSDK::CSQLAccess &sqlAccess ) OVERRIDE;
  44. virtual bool BYieldingAddWriteToTransaction( GCSDK::CSQLAccess &sqlAccess, const CUtlVector< int > &fields ) OVERRIDE;
  45. virtual bool BYieldingAddRemoveToTransaction( GCSDK::CSQLAccess &sqlAccess ) OVERRIDE;
  46. virtual bool BAddToMessage( CUtlBuffer & bufOutput ) const OVERRIDE;
  47. virtual bool BAddToMessage( std::string *pBuffer ) const OVERRIDE;
  48. virtual bool BAddDestroyToMessage( CUtlBuffer & bufDestroy ) const OVERRIDE;
  49. virtual bool BAddDestroyToMessage( std::string *pBuffer ) const OVERRIDE;
  50. #endif
  51. virtual bool BParseFromMessage( const CUtlBuffer & buffer ) OVERRIDE;
  52. virtual bool BParseFromMessage( const std::string &buffer ) OVERRIDE;
  53. virtual bool BUpdateFromNetwork( const CSharedObject & objUpdate ) OVERRIDE;
  54. virtual void Copy( const CSharedObject & soRHS );
  55. virtual void Dump() const;
  56. void SerializeToProtoBufItem( CSOClassPresetClientData &msgPresetInstance ) const;
  57. void DeserializeFromProtoBufItem( const CSOClassPresetClientData &msgPresetIntance );
  58. enum
  59. {
  60. kPerClassPresetDataDirtyField_ActivePreset,
  61. kPerClassPresetDataDirtyField_PresetData_Base,
  62. };
  63. #ifdef GC_DLL
  64. const CUtlVector<PresetSlotItem_t> *FindItemsForPresetIndex( equipped_preset_t unPreset ) const;
  65. void EquipItemIntoActivePresetSlot( equipped_slot_t unSlot, itemid_t unOriginalItemID );
  66. void RemoveAllItemsFromPresetIndex( equipped_preset_t unPreset );
  67. void SetActivePreset( equipped_preset_t unPreset );
  68. equipped_class_t GetClass() const { return m_unClassID; }
  69. #endif // GC_DLL
  70. equipped_preset_t GetActivePreset() const { return m_unActivePreset; }
  71. private:
  72. CEconItemPerClassPresetData( const CEconItemPerClassPresetData& ) = delete;
  73. void operator=( const CEconItemPerClassPresetData& ) = delete;
  74. private:
  75. uint32 m_unAccountID;
  76. equipped_class_t m_unClassID;
  77. equipped_preset_t m_unActivePreset;
  78. CUtlVector<PresetSlotItem_t> m_PresetData[ CEconItemSchema::kMaxItemPresetCount ];
  79. };
  80. #endif // ECONITEMPRESET_H