RNCDecompressor.hpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* Copyright (C) Teemu Suutari */
  2. #ifndef RNCDECOMPRESSOR_HPP
  3. #define RNCDECOMPRESSOR_HPP
  4. #include "Decompressor.hpp"
  5. namespace ancient::internal
  6. {
  7. class RNCDecompressor : public Decompressor
  8. {
  9. public:
  10. RNCDecompressor(const Buffer &packedData,bool verify);
  11. virtual ~RNCDecompressor();
  12. virtual const std::string &getName() const noexcept override final;
  13. virtual size_t getPackedSize() const noexcept override final;
  14. virtual size_t getRawSize() const noexcept override final;
  15. virtual void decompressImpl(Buffer &rawData,bool verify) override final;
  16. static bool detectHeader(uint32_t hdr) noexcept;
  17. static std::shared_ptr<Decompressor> create(const Buffer &packedData,bool exactSizeKnown,bool verify);
  18. private:
  19. enum class Version
  20. {
  21. RNC1Old=0,
  22. RNC1New,
  23. RNC2
  24. };
  25. void RNC1DecompressOld(Buffer &rawData,bool verify);
  26. void RNC1DecompressNew(Buffer &rawData,bool verify);
  27. void RNC2Decompress(Buffer &rawData,bool verify);
  28. const Buffer &_packedData;
  29. uint32_t _rawSize=0;
  30. uint32_t _packedSize=0;
  31. uint16_t _rawCRC=0;
  32. uint8_t _chunks=0;
  33. Version _ver;
  34. };
  35. }
  36. #endif