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.

53 lines
1.7 KiB

  1. //===== Copyright c 1996-2008, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #include "resourcefile/resourcefile.h"
  8. #include "tier0/dbg.h"
  9. // Must be last
  10. #include "tier0/memdbgon.h"
  11. #ifdef OSX
  12. #pragma GCC diagnostic ignored "-Wbool-conversions"
  13. #endif
  14. //-----------------------------------------------------------------------------
  15. // Does this resource file contain a particular block?
  16. //-----------------------------------------------------------------------------
  17. bool Resource_IsBlockDefined( const ResourceFileHeader_t *pHeader, ResourceBlockId_t id )
  18. {
  19. Assert( pHeader->m_nVersion == RESOURCE_FILE_HEADER_VERSION );
  20. if ( pHeader->m_nVersion != RESOURCE_FILE_HEADER_VERSION )
  21. return false;
  22. for ( int i = 0; i < pHeader->m_ResourceBlocks.Count(); ++i )
  23. {
  24. const ResourceBlockEntry_t &block = pHeader->m_ResourceBlocks[i];
  25. if ( block.m_nBlockType == id )
  26. return true;
  27. }
  28. return false;
  29. }
  30. //-----------------------------------------------------------------------------
  31. // Gets the data associated with a particular data block
  32. //-----------------------------------------------------------------------------
  33. const void *Resource_GetBlock( const ResourceFileHeader_t *pHeader, ResourceBlockId_t id )
  34. {
  35. Assert( pHeader->m_nVersion == RESOURCE_FILE_HEADER_VERSION );
  36. if ( pHeader->m_nVersion != RESOURCE_FILE_HEADER_VERSION )
  37. return NULL;
  38. for ( int i = 0; i < pHeader->m_ResourceBlocks.Count(); ++i )
  39. {
  40. const ResourceBlockEntry_t &block = pHeader->m_ResourceBlocks[i];
  41. if ( block.m_nBlockType == id )
  42. return block.m_pBlockData;
  43. }
  44. return NULL;
  45. }