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.

536 lines
23 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. #ifndef ECONITEMDESCRIPTION_H
  3. #define ECONITEMDESCRIPTION_H
  4. #ifdef _WIN32
  5. #pragma once
  6. #endif
  7. #include "localization_provider.h" // needed for locchar_t type
  8. #if defined( TF_DLL ) || defined( TF_CLIENT_DLL ) || defined( TF_GC_DLL )
  9. #define PROJECT_TF
  10. #endif
  11. #define TF_ANTI_IDLEBOT_VERIFICATION defined( PROJECT_TF )
  12. #if TF_ANTI_IDLEBOT_VERIFICATION
  13. #define TF_ANTI_IDLEBOT_VERIFICATION_ONLY_COMMA ,
  14. #define TF_ANTI_IDLEBOT_VERIFICATION_ONLY_ARG( arg ) arg
  15. #else
  16. #define TF_ANTI_IDLEBOT_VERIFICATION_ONLY_COMMA
  17. #define TF_ANTI_IDLEBOT_VERIFICATION_ONLY_ARG( arg )
  18. #endif
  19. #if TF_ANTI_IDLEBOT_VERIFICATION
  20. #include "checksum_md5.h"
  21. #include "tf_gcmessages.pb.h"
  22. #include "tf_gcmessages.h"
  23. #ifdef CLIENT_DLL
  24. #include "gc_clientsystem.h"
  25. #endif // CLIENT_DLL
  26. #endif // TF_ANTI_IDLEBOT_VERIFICATION
  27. #ifdef GC_DLL
  28. #include "gcsdk/gclogger.h"
  29. using namespace GCSDK;
  30. #endif
  31. class IEconItemInterface;
  32. namespace GCSDK
  33. {
  34. class CSharedObjectTypeCache;
  35. }
  36. //-----------------------------------------------------------------------------
  37. // Purpose: Generate a description block for an IEconItemInterface. What the
  38. // client does with the description is anyone's guess, but this will
  39. // generate a block of UTF16 lines of text with meta/color data that
  40. // can be used for whatever.
  41. //-----------------------------------------------------------------------------
  42. enum EDescriptionLineMetaFlags
  43. {
  44. kDescLineFlag_Name = 0x001, // the item name (can be renamed by user)
  45. kDescLineFlag_Type = 0x002, // the item type (ie., "Level 5 Rocket Launcher")
  46. kDescLineFlag_Desc = 0x004, // base item description (description from the item definition, level, etc.)
  47. kDescLineFlag_Attribute = 0x008, // some sort of gameplay-affecting attribute
  48. kDescLineFlag_Misc = 0x010, // not an attribute, not name/level
  49. kDescLineFlag_Empty = 0x020, // line with no content that needs to be displayed; meant for spacing
  50. kDescLineFlag_Set = 0x040, // this line is associated with item sets somehow
  51. kDescLineFlag_LimitedUse= 0x080, // this is a limited use item
  52. kDescLineFlag_SetName = 0x100, // this line is the title for an item set
  53. kDescLineFlag_Collection = 0x200, // this line is associated with item collections
  54. kDescLineFlag_CollectionCurrentItem = 0x400, // this line is the current item being describe
  55. kDescLineFlag_CollectionName = 0x800, // this line is the collection name
  56. kDescLineFlagSet_DisplayInAttributeBlock = ~(kDescLineFlag_Name | kDescLineFlag_Type),
  57. };
  58. struct econ_item_description_line_t
  59. {
  60. attrib_colors_t eColor; // desired color type for this line -- will likely be looked up either in VGUI or in the schema
  61. uint32 unMetaType; // type information for this line -- "item name"? "item level"?; etc.; can be game-specific
  62. CUtlConstStringBase<locchar_t> sText; // actual text for this, post-localization
  63. item_definition_index_t unDefIndex; // item def index for description lines which represent names of other items (used by bundles)
  64. bool bIsItemForSale; // if this line is an item (eg in the case where a bundle description lists its contained items) - is the given item for sale?
  65. };
  66. class IEconItemDescription
  67. {
  68. public:
  69. // This may yield on the GC and should never yield on the client.
  70. static void YieldingFillOutEconItemDescription( IEconItemDescription *out_pDescription, CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  71. public:
  72. IEconItemDescription() { }
  73. virtual ~IEconItemDescription() { }
  74. uint32 GetLineCount() const { return m_vecDescLines.Count(); }
  75. const econ_item_description_line_t& GetLine( int i ) const { return m_vecDescLines[i]; }
  76. // Finds and returns the first line with *all* of the passed in search flags. Will return NULL if a line
  77. // will all of the flags cannot be found.
  78. const econ_item_description_line_t *GetFirstLineWithMetaType( uint32 unMetaTypeSearchFlags ) const;
  79. private:
  80. // When generating an item description, this is guaranteed to be called once and only once before GenerateDescription()
  81. // is called. Any data that may yield but will be needed somewhere deep inside GenerateDescription() should be determined
  82. // and cached off here.
  83. virtual void YieldingCacheDescriptionData( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem ) { }
  84. // Take the properties off our pEconItem, and anything that we calculated in YieldingCacheDescriptionData() above and
  85. // fill out all of our description lines.
  86. virtual void GenerateDescriptionLines( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem ) = 0;
  87. protected:
  88. CUtlVector<econ_item_description_line_t> m_vecDescLines;
  89. };
  90. // This will be defined as either 1 or 0 depending on which project we're in. We test its value explicitly
  91. // rather than just checking defined() because otherwise failing to include this header file will silently
  92. // result in it appearing to be undefined.
  93. #define BUILD_ITEM_NAME_AND_DESC (defined( CLIENT_DLL ) || defined( GC_DLL ))
  94. #if BUILD_ITEM_NAME_AND_DESC
  95. //-----------------------------------------------------------------------------
  96. // Purpose:
  97. //-----------------------------------------------------------------------------
  98. class IAccountPersonaLocalizer
  99. {
  100. public:
  101. virtual const locchar_t *FindAccountPersonaName( uint32 unAccountID ) const = 0;
  102. };
  103. //-----------------------------------------------------------------------------
  104. // Purpose:
  105. //-----------------------------------------------------------------------------
  106. class CEconItemDescription : public IEconItemDescription, public IAccountPersonaLocalizer
  107. {
  108. public:
  109. // Instances should be filled out via YieldingFillOutEconItemDescription().
  110. CEconItemDescription()
  111. #if TF_ANTI_IDLEBOT_VERIFICATION
  112. : m_pHashContext( NULL )
  113. , m_bIsVerbose( false )
  114. #ifdef GC_DLL
  115. , m_bTextModeEnabled( false )
  116. #else // if defined( CLIENT_DLL )
  117. , m_bUnknownPlayer( false )
  118. #endif // GC_DLL
  119. #endif // TF_ANTI_IDLEBOT_VERIFICATION
  120. {
  121. //
  122. }
  123. // External helper interface, also used internally. This should only be used to add lines
  124. // that are not a part of the properties of the item, but are instead a part of the environment
  125. // around the item (ie., "this item cannot be equipped in this slot because another item is
  126. // equipped that has conflicting regions").
  127. //
  128. // The final argument is an optional target array to use for the description lines instead of
  129. // our internal storage. We can use this to queue up and then batch-submit/-discard lines. Passing
  130. // in NULL means "use the internal array".
  131. virtual void AddDescLine( const locchar_t *pString, attrib_colors_t eColor, uint32 unMetaType, CUtlVector<econ_item_description_line_t> *out_pOptionalDescLineDest = NULL, item_definition_index_t unDefIndex = INVALID_ITEM_DEF_INDEX, bool bIsItemForSale = true );
  132. virtual void AddEmptyDescLine( CUtlVector<econ_item_description_line_t> *out_pOptionalDescLineDest = NULL );
  133. virtual void LocalizedAddDescLine( const CLocalizationProvider *pLocalizationProvider, const char *pLocalizationToken, attrib_colors_t eColor, uint32 unMetaType, CUtlVector<econ_item_description_line_t> *out_pOptionalDescLineDest = NULL, item_definition_index_t unDefIndex = INVALID_ITEM_DEF_INDEX, bool bIsItemForSale = true );
  134. // A helper class to iterate all attributes that we expect to appear on an item description. This
  135. // is useable from outside CEconItemDescription. Attributes can be accessed in iteration order or
  136. // manually sorted to be grouped by positive/negative status, etc.
  137. class CVisibleAttributeDisplayer : public IEconItemAttributeIterator
  138. {
  139. public:
  140. virtual bool OnIterateAttributeValue( const CEconItemAttributeDefinition *pAttrDef, attrib_value_t value ) OVERRIDE;
  141. virtual bool OnIterateAttributeValue( const CEconItemAttributeDefinition *pAttrDef, float value ) OVERRIDE
  142. {
  143. return true;
  144. }
  145. virtual bool OnIterateAttributeValue( const CEconItemAttributeDefinition *pAttrDef, const uint64& value ) OVERRIDE
  146. {
  147. return true;
  148. }
  149. virtual bool OnIterateAttributeValue( const CEconItemAttributeDefinition *pAttrDef, const CAttribute_String& value ) OVERRIDE
  150. {
  151. return true;
  152. }
  153. virtual bool OnIterateAttributeValue( const CEconItemAttributeDefinition *pAttrDef, const CAttribute_DynamicRecipeComponent& value ) OVERRIDE
  154. {
  155. // Don't show these
  156. return true;
  157. }
  158. virtual bool OnIterateAttributeValue( const CEconItemAttributeDefinition *pAttrDef, const CAttribute_ItemSlotCriteria& value ) OVERRIDE
  159. {
  160. // Don't show these
  161. return true;
  162. }
  163. virtual bool OnIterateAttributeValue( const CEconItemAttributeDefinition *pAttrDef, const CAttribute_WorldItemPlacement& value ) OVERRIDE
  164. {
  165. // Don't show these
  166. return true;
  167. }
  168. void SortAttributes();
  169. void Finalize( const IEconItemInterface *pEconItem, CEconItemDescription *pEconItemDescription, const CLocalizationProvider *pLocalizationProvider );
  170. private:
  171. struct attrib_iterator_value_t
  172. {
  173. const CEconItemAttributeDefinition *m_pAttrDef;
  174. attrib_value_t m_value;
  175. };
  176. CUtlVector<attrib_iterator_value_t> m_vecAttributes;
  177. };
  178. class CRecipeNameAttributeDisplayer : public CVisibleAttributeDisplayer
  179. {
  180. public:
  181. virtual bool OnIterateAttributeValue( const CEconItemAttributeDefinition *pAttrDef, attrib_value_t value ) OVERRIDE;
  182. };
  183. #if TF_ANTI_IDLEBOT_VERIFICATION
  184. void SetHashContext( MD5Context_t *pHashContext )
  185. {
  186. AssertMsg( pHashContext == NULL || m_pHashContext == NULL, "Only one hash context allowed per item description!" );
  187. m_pHashContext = pHashContext;
  188. }
  189. void SetVerbose( bool bIsVerbose )
  190. {
  191. m_bIsVerbose = bIsVerbose;
  192. }
  193. #ifdef GC_DLL
  194. void SetHashGCTextModeEnabled( bool bTextModeEnabled )
  195. {
  196. m_bTextModeEnabled = bTextModeEnabled;
  197. }
  198. #endif // GC_DLL
  199. #endif // TF_ANTI_IDLEBOT_VERIFICATION
  200. #ifdef GC_DLL
  201. bool HasUnknownPlayer( ) const
  202. {
  203. return false;
  204. }
  205. #else // if defined( CLIENT_DLL )
  206. bool HasUnknownPlayer( ) const
  207. {
  208. return m_bUnknownPlayer;
  209. }
  210. #endif
  211. private:
  212. // IEconItemDescription interface.
  213. virtual void YieldingCacheDescriptionData( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  214. virtual void GenerateDescriptionLines( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  215. private:
  216. // Internal.
  217. virtual void AddAttributeDescription( const CLocalizationProvider *pLocalizationProvider, const CEconItemAttributeDefinition *pAttribDef, attrib_value_t value, attrib_colors_t eOverrideDisplayColor = NUM_ATTRIB_COLORS );
  218. virtual void Generate_ItemName( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  219. virtual void Generate_ItemLevelDesc( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  220. #if defined( STAGING_ONLY ) && defined( CLIENT_DLL )
  221. virtual void Generate_DebugInformation( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  222. #endif // defined( DEBUG ) && defined( CLIENT_DLL )
  223. virtual void Generate_CraftTag( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  224. virtual void Generate_StyleDesc( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  225. virtual void Generate_HolidayRestriction( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  226. virtual void Generate_QualityDesc( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  227. virtual void Generate_ItemRarityDesc( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  228. virtual void Generate_WearAmountDesc( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  229. virtual void Generate_ItemDesc( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  230. virtual void Generate_Bundle( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  231. virtual void Generate_GiftedBy( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  232. #ifdef PROJECT_TF
  233. virtual void Generate_DuelingMedal( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  234. virtual void Generate_MapContributor( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  235. virtual void Generate_FriendlyHat( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  236. virtual void Generate_SaxxyAwardDesc( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  237. virtual void Generate_MvmChallenges( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  238. virtual void Generate_SquadSurplusClaimedBy( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  239. virtual void Generate_DynamicRecipe( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  240. virtual void Generate_Leaderboard( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  241. #endif // PROJECT_TF
  242. virtual void Generate_XifierToolTargetItem( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  243. virtual void Generate_Painted( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  244. virtual void Generate_Uses( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  245. virtual void Generate_LootListDesc( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  246. virtual void Generate_EventDetail( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  247. virtual void Generate_ItemSetDesc( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  248. virtual void Generate_CollectionDesc( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  249. virtual void Generate_ExpirationDesc( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  250. virtual void Generate_MarketInformation( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  251. virtual void Generate_FlagsAttributes( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  252. virtual void Generate_DropPeriodDesc( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  253. virtual void Generate_VisibleAttributes( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  254. virtual void Generate_DirectX8Warning( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  255. // Helpers for the above.
  256. virtual void Generate_ItemLevelDesc_Default( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem, const locchar_t *locTypename );
  257. virtual bool BGenerate_ItemLevelDesc_StrangeNameAndStats( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem, const locchar_t *locTypename ); // returns true if generated a level/desc based on strange stats or false if nothing was generated
  258. const locchar_t *GetLocalizedStringForStrangeRestrictionAttr( const CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem, int iAttrIndex ) const;
  259. // Internal data.
  260. void YieldingFillOutAccountPersonaName( const CLocalizationProvider *pLocalizationProvider, uint32 unAccountID );
  261. const locchar_t *FindAccountPersonaName( uint32 unAccountID ) const;
  262. void YieldingFillOutAccountTypeCache( uint32 unAccountID, int nClassID );
  263. GCSDK::CSharedObjectTypeCache *FindAccountTypeCache( uint32 unAccountID, int nClassID ) const;
  264. // Defined in source file -- not meant for external access.
  265. template < typename T >
  266. const T *FindAccountTypeCacheSingleton( uint32 unAccountID, int nClassID ) const;
  267. // Precache data.
  268. struct steam_account_persona_name_t
  269. {
  270. uint32 unAccountID;
  271. CUtlConstStringBase<locchar_t> loc_sPersonaName;
  272. };
  273. CUtlVector<steam_account_persona_name_t> vecPersonaNames;
  274. struct steam_account_type_cache_t
  275. {
  276. uint32 unAccountID;
  277. int nClassID;
  278. GCSDK::CSharedObjectTypeCache *pTypeCache;
  279. };
  280. CUtlVector<steam_account_type_cache_t> vecTypeCaches;
  281. #if TF_ANTI_IDLEBOT_VERIFICATION
  282. MD5Context_t *m_pHashContext;
  283. bool m_bIsVerbose;
  284. #ifdef GC_DLL
  285. bool m_bTextModeEnabled;
  286. #else // if defined( CLIENT_DLL )
  287. bool m_bUnknownPlayer;
  288. #endif // GC_DLL
  289. #endif // TF_ANTI_IDLEBOT_VERIFICATION
  290. };
  291. //-----------------------------------------------------------------------------
  292. // Purpose:
  293. //-----------------------------------------------------------------------------
  294. class CEconAttributeDescription
  295. {
  296. private:
  297. // Internal constructor.
  298. void InternalConstruct
  299. (
  300. const CLocalizationProvider *pLocalizationProvider,
  301. const CEconItemAttributeDefinition *pAttribDef,
  302. attrib_value_t value,
  303. TF_ANTI_IDLEBOT_VERIFICATION_ONLY_ARG( MD5Context_t *pHashContext ) TF_ANTI_IDLEBOT_VERIFICATION_ONLY_COMMA
  304. IAccountPersonaLocalizer *pOptionalAccountPersonaLocalizer
  305. );
  306. public:
  307. // Outward-facing constructor. Pass in whatever you want for "value" and we'll
  308. // use the raw bits for their value interpreted however the attribute says.
  309. template < typename T >
  310. CEconAttributeDescription
  311. (
  312. const CLocalizationProvider *pLocalizationProvider,
  313. const CEconItemAttributeDefinition *pAttribDef,
  314. T value,
  315. TF_ANTI_IDLEBOT_VERIFICATION_ONLY_ARG( MD5Context_t *pHashContext = NULL ) TF_ANTI_IDLEBOT_VERIFICATION_ONLY_COMMA
  316. IAccountPersonaLocalizer *pOptionalAccountPersonaLocalizer = NULL
  317. )
  318. {
  319. COMPILE_TIME_ASSERT( sizeof( T ) == sizeof( attrib_value_t ) );
  320. InternalConstruct( pLocalizationProvider, pAttribDef, *(attrib_value_t *)&value, TF_ANTI_IDLEBOT_VERIFICATION_ONLY_ARG( pHashContext ) TF_ANTI_IDLEBOT_VERIFICATION_ONLY_COMMA pOptionalAccountPersonaLocalizer );
  321. }
  322. const CUtlConstStringBase<locchar_t>& GetDescription() const { return m_loc_sValue; }
  323. const CUtlConstStringBase<locchar_t>& GetShortDescription() const { return m_loc_sShortValue; }
  324. attrib_colors_t GetDefaultColor() const { return m_eDefaultColor; }
  325. private:
  326. CUtlConstStringBase<locchar_t> m_loc_sValue;
  327. CUtlConstStringBase<locchar_t> m_loc_sShortValue;
  328. attrib_colors_t m_eDefaultColor;
  329. };
  330. //-----------------------------------------------------------------------------
  331. // Purpose: control how item name is generated
  332. //-----------------------------------------------------------------------------
  333. enum EGenerateLocalizedFullItemNameFlag_t
  334. {
  335. k_EGenerateLocalizedFullItemName_Default = 0,
  336. k_EGenerateLocalizedFullItemName_WithPaintWear = ( 1 << 0 ),
  337. k_EGenerateLocalizedFullItemName_WithoutCustomName = ( 1 << 1 ),
  338. k_EGenerateLocalizedFullItemName_WithoutQuality = ( 1 << 2 ),
  339. k_EGenerateLocalizedFullItemName_WithPaintkitNoItem = ( 1 << 3 ),
  340. };
  341. //-----------------------------------------------------------------------------
  342. // Purpose:
  343. //-----------------------------------------------------------------------------
  344. class CEconItemLocalizedFullNameGenerator
  345. {
  346. public:
  347. CEconItemLocalizedFullNameGenerator( const CLocalizationProvider *pLocalizationProvider, const CEconItemDefinition *pItemDef, bool bUseingHashContext = true, entityquality_t eQuality = AE_UNIQUE );
  348. const locchar_t *GetFullName() const { return m_loc_LocalizedItemName; }
  349. private:
  350. locchar_t m_loc_LocalizedItemName[ MAX_ITEM_NAME_LENGTH ];
  351. };
  352. //-----------------------------------------------------------------------------
  353. // Purpose:
  354. //-----------------------------------------------------------------------------
  355. class CEconItemLocalizedMarketNameGenerator
  356. {
  357. public:
  358. CEconItemLocalizedMarketNameGenerator( const CLocalizationProvider *pLocalizationProvider, CEconItem *pItem, bool bUseingHashContext = true );
  359. const locchar_t *GetFullName() const { return m_loc_LocalizedItemName; }
  360. private:
  361. locchar_t m_loc_LocalizedItemName[ MAX_ITEM_NAME_LENGTH ];
  362. };
  363. //-----------------------------------------------------------------------------
  364. // Purpose:
  365. //-----------------------------------------------------------------------------
  366. class CSteamAccountIDAttributeCollector : public CEconItemSpecificAttributeIterator
  367. {
  368. public:
  369. virtual bool OnIterateAttributeValue( const CEconItemAttributeDefinition *pAttrDef, attrib_value_t value ) OVERRIDE
  370. {
  371. if ( pAttrDef->GetDescriptionFormat() == ATTDESCFORM_VALUE_IS_ACCOUNT_ID )
  372. {
  373. m_vecSteamAccountIDs.AddToTail( value );
  374. }
  375. return true;
  376. }
  377. // Data access.
  378. const CUtlVector<uint32>& GetAccountIDs()
  379. {
  380. return m_vecSteamAccountIDs;
  381. }
  382. private:
  383. CUtlVector<uint32> m_vecSteamAccountIDs;
  384. };
  385. // --------------------------------------------------------------------------
  386. // Purpose:
  387. // --------------------------------------------------------------------------
  388. #if TF_ANTI_IDLEBOT_VERIFICATION
  389. #include "checksum_md5.h"
  390. enum
  391. {
  392. kTFDescriptionHash_TextmodeArbitraryKey = 0x19a04480,
  393. kTFDescriptionHash_ValidArbitraryKey = 0xa0939180,
  394. kTFDescriptionHash_MultiRunArbitraryKey = 0x5790a31d,
  395. kTFDescriptionHash_ChallengeXorShenanigans = 0x1870f0d2,
  396. };
  397. // Global function/variable names show up in Mac binaries so we give them names that will stand out less
  398. // here and then #define them back so the code is readable.
  399. #define TF_Description_HashDataMungeContents CompressFragments
  400. inline void TFDescription_HashDataMungeContents( MD5Context_t *out_pContext, const void *pContents, size_t unContentLength, bool bIsVerbose, const char* pszInfo )
  401. {
  402. Assert( out_pContext );
  403. Assert( pContents );
  404. MD5Update( out_pContext, static_cast<const uint8 *>( pContents ), unContentLength );
  405. // if Verbose, report the contents to the GC
  406. if ( bIsVerbose )
  407. {
  408. MD5Context_t md5ContextEx = *out_pContext;
  409. MD5Value_t md5ResultEx;
  410. MD5Final( &md5ResultEx.bits[0], &md5ContextEx );
  411. #ifdef GC_DLL
  412. EmitInfo( SPEW_GC, SPEW_ALWAYS, LOG_ALWAYS, "Verbose Verification GC : [ %s ] - [ %s ] \n", MD5_Print( md5ResultEx.bits, MD5_DIGEST_LENGTH ), pszInfo );
  413. #else
  414. // Client reports this to the GC
  415. GCSDK::CProtoBufMsg<CGCMsgTFSyncEx> msgResponse( k_EMsgGC_ClientVerificationVerboseResponse );
  416. msgResponse.Body().set_version_checksum( pszInfo ); // before
  417. msgResponse.Body().set_version_checksum_ex( &md5ResultEx.bits[0], MD5_DIGEST_LENGTH ); // after
  418. GCClientSystem()->BSendMessage( msgResponse );
  419. #endif
  420. //delete [] pArr;
  421. }
  422. }
  423. // Okay, this one is actually just a helper macro.
  424. #define TFDescription_HashDataMunge( context, field, bIsVerbose, pszInfo ) \
  425. { \
  426. TFDescription_HashDataMungeContents( context, (void *)&field, sizeof( field ), bIsVerbose, pszInfo ); \
  427. }
  428. #endif // TF_ANTI_IDLEBOT_VERIFICATION
  429. #endif // BUILD_ITEM_NAME_AND_DESC
  430. // --------------------------------------------------------------------------
  431. // Purpose:
  432. // --------------------------------------------------------------------------
  433. struct CLocalizedRTime32
  434. {
  435. RTime32 m_unTime;
  436. bool m_bForceGMTOnClient; // display this time in GMT on the client? by default, clients show local time; the GC will ignore this flag and always display GMT
  437. const CLocalizationProvider *m_pLocalizationProvider;
  438. TF_ANTI_IDLEBOT_VERIFICATION_ONLY_ARG( MD5Context_t *m_pHashContext; )
  439. };
  440. template < >
  441. class CLocalizedStringArg<CLocalizedRTime32>
  442. {
  443. public:
  444. enum { kIsValid = true };
  445. CLocalizedStringArg( const CLocalizedRTime32& cTimeIn );
  446. const locchar_t *GetLocArg() const { return m_Str.Get(); }
  447. private:
  448. CUtlConstStringBase<locchar_t> m_Str;
  449. };
  450. #endif // ECONITEMDESCRIPTION_H