FieldFile.cpp 965 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #include "FieldFile.h"
  2. #include "ArchiveFile.h"
  3. FieldFile::FieldFile( const Ogre::String& file ):
  4. File( file )
  5. {
  6. }
  7. FieldFile::FieldFile(File* file, const u32 offset, const u32 length ):
  8. File( file, offset, length )
  9. {
  10. }
  11. FieldFile::FieldFile( u8* buffer, const u32 offset, const u32 length ):
  12. File( buffer, offset, length )
  13. {
  14. }
  15. FieldFile::FieldFile( File* file ):
  16. File( file )
  17. {
  18. }
  19. FieldFile::~FieldFile()
  20. {
  21. }
  22. File*
  23. FieldFile::Extract( const int file_number )
  24. {
  25. // there are only 8 files
  26. if( file_number > 8 )
  27. {
  28. return NULL;
  29. }
  30. u32 length_uncompressed = GetU32LE( 0x010c + file_number * 0x04 );
  31. u32 first_file = GetU32LE( 0x0130 + file_number * 0x04);
  32. u32 length = GetU32LE( 0x0130 + ( file_number + 1 ) * 0x04) - first_file;
  33. ArchiveFile* comp = new ArchiveFile( this, first_file, length );
  34. File* file = new File( comp, 0, length_uncompressed );
  35. delete comp;
  36. return file;
  37. }