Counter Strike : Global Offensive Source Code
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.

77 lines
1.6 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef CAPTIONCOMPILER_H
  7. #define CAPTIONCOMPILER_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "datamap.h"
  12. #include "checksum_crc.h"
  13. #define MAX_BLOCK_BITS 13
  14. #define MAX_BLOCK_SIZE (1<<MAX_BLOCK_BITS )
  15. #define COMPILED_CAPTION_FILEID MAKEID( 'V', 'C', 'C', 'D' )
  16. #define COMPILED_CAPTION_VERSION 1
  17. #pragma pack(1)
  18. struct CompiledCaptionHeader_t
  19. {
  20. DECLARE_BYTESWAP_DATADESC()
  21. int magic;
  22. int version;
  23. int numblocks;
  24. int blocksize;
  25. int directorysize;
  26. int dataoffset;
  27. };
  28. struct CaptionLookup_t
  29. {
  30. DECLARE_BYTESWAP_DATADESC()
  31. unsigned int hash;
  32. int blockNum;
  33. unsigned short offset;
  34. unsigned short length;
  35. void SetHash( char const *string )
  36. {
  37. int len = Q_strlen( string );
  38. char *tempstr = (char *)stackalloc( len + 1 );
  39. Q_strncpy( tempstr, string, len + 1 );
  40. Q_strlower( tempstr );
  41. CRC32_t temp;
  42. CRC32_Init( &temp );
  43. CRC32_ProcessBuffer( &temp, tempstr, len );
  44. CRC32_Final( &temp );
  45. hash = ( unsigned int )temp;
  46. }
  47. };
  48. #pragma pack()
  49. class CCaptionLookupLess
  50. {
  51. public:
  52. bool Less( const CaptionLookup_t& lhs, const CaptionLookup_t& rhs, void *pContext )
  53. {
  54. return lhs.hash < rhs.hash;
  55. }
  56. };
  57. struct CaptionBlock_t
  58. {
  59. byte data[ MAX_BLOCK_SIZE ];
  60. };
  61. // For swapping compiled caption files
  62. bool SwapClosecaptionFile( void *pData );
  63. int UpdateOrCreateCaptionFile( const char *pSourceName, char *pTargetName, int targetLen, bool bForce = false );
  64. #endif // CAPTIONCOMPILER_H