@@ -31,11 +31,13 @@ namespace libbndl
3131 BND2 = 2
3232 };
3333
34- enum class Platform : uint32_t
34+ enum class Platform : uint16_t
3535 {
3636 PC = 1 , // (or PS4/XB1)
3737 Xbox360 = 2 ,
38- PS3 = 3
38+ PS3 = 3 ,
39+ PSVita = 4 ,
40+ WiiU = 5
3941 };
4042
4143 namespace ResourceType
@@ -307,9 +309,11 @@ namespace libbndl
307309 MainMemory = 0 ,
308310
309311 GraphicsSystem = 1 , // PS3
310- Physical = 1 , // X360
312+ Physical = 1 , // Xbox 360
313+ Mem1 = 1 , // Wii U
311314
312315 GraphicsLocal = 2 , // PS3
316+ GraphicsMem2 = 2 , // Wii U
313317
314318 Disposable = 3 // PC in Burnout, all in NFS
315319 };
@@ -326,7 +330,8 @@ namespace libbndl
326330 HasDebugData = 0x8 ,
327331 NonAsynchFixupRequired = 0x10 ,
328332 MultistreamBundle = 0x20 ,
329- DeltaBundle = 0x40
333+ DeltaBundle = 0x40 ,
334+ ContainsDefaultResource = 0x80
330335 };
331336
332337 public:
@@ -391,16 +396,18 @@ namespace libbndl
391396 DeltaBundle = 0xC0
392397 };
393398
399+ constexpr ResourceID () noexcept : m_id(0 ) {}
394400 constexpr ResourceID (uint32_t id, uint16_t type, uint8_t index, EIDType idType) noexcept
395401 : m_id(id | (static_cast <uint64_t >(type) << 32) | (static_cast <uint64_t >(index) << 48) || (static_cast <uint64_t >(idType) << 56)) {}
396402 constexpr explicit ResourceID (UnderlyingType id) noexcept : m_id(id) {}
397403
404+ [[nodiscard]] constexpr bool operator ==(const ResourceID &id) const noexcept = default ;
398405 [[nodiscard]] constexpr auto operator <=>(const ResourceID &flags) const noexcept = default ;
399406 [[nodiscard]] constexpr auto operator ==(UnderlyingType id) const noexcept { return m_id == id; };
400407
401408 [[nodiscard]] constexpr uint32_t GetGameChangerID () const noexcept { return m_id & 0xFFFFFFFF ; }
402409 [[nodiscard]] constexpr uint32_t GetID32 () const noexcept { return GetGameChangerID (); }
403- [[nodiscard]] constexpr uint16_t GetTypeID () const noexcept { return (m_id >> 32 ) & 0xFFFF ; }
410+ [[nodiscard]] constexpr uint16_t GetResourceTypeID () const noexcept { return (m_id >> 32 ) & 0xFFFF ; }
404411 [[nodiscard]] constexpr uint8_t GetIndex () const noexcept { return (m_id >> 48 ) & 0xFF ; }
405412 [[nodiscard]] constexpr EIDType GetIDType () const noexcept { return static_cast <EIDType>((m_id >> 56 ) & 0xFF ); }
406413
@@ -488,59 +495,62 @@ namespace libbndl
488495 class Resource
489496 {
490497 public:
491- Resource (std::array<Buffer, 4 > buffers, std::vector<Import> imports, uint8_t streamIndex ) : m_buffers(std::move(buffers)), m_imports(std::move(imports)), m_streamIndex(streamIndex ) {}
498+ Resource (std::array<Buffer, 4 > buffers, std::vector<Import> imports) : m_buffers(std::move(buffers)), m_imports(std::move(imports)) {}
492499
493500 [[nodiscard]] constexpr const Buffer &GetBinary (MemoryType block) const { return m_buffers[LIBBNDL_TO_UNDERLYING (block)]; }
494501 [[nodiscard]] constexpr const std::vector<Import> GetImports () const { return m_imports; }
495- [[nodiscard]] constexpr const uint8_t GetStreamIndex () const { return m_streamIndex; }
496502
497503 void ReplaceBinary (MemoryType block, Buffer &&buffer) { m_buffers[LIBBNDL_TO_UNDERLYING (block)] = std::move (buffer); }
498504
499505 private:
500506 std::array<Buffer, 4 > m_buffers;
501507 std::vector<Import> m_imports;
502- uint8_t m_streamIndex;
503508 };
504509
505510 class Bundle
506511 {
507512 public:
508513 LIBBNDL_EXPORT Bundle ();
509- LIBBNDL_EXPORT Bundle (MagicNumber magicNumber, uint32_t version, Platform platform, Flags flags); // For creating new bundles
514+ LIBBNDL_EXPORT Bundle (MagicNumber magicNumber, uint16_t version, Platform platform, Flags flags); // For creating new bundles
510515 LIBBNDL_EXPORT ~Bundle ();
511516
512517 LIBBNDL_EXPORT bool Load (const std::string &name);
513518 LIBBNDL_EXPORT bool Save (const std::string &name);
514519
515- LIBBNDL_EXPORT [[nodiscard]] MagicNumber GetMagicNumber () const ;
516- LIBBNDL_EXPORT [[nodiscard]] uint32_t GetVersion () const ;
517- LIBBNDL_EXPORT [[nodiscard]] Platform GetPlatform () const ;
518- LIBBNDL_EXPORT [[nodiscard]] Flags GetFlags () const ;
520+ [[nodiscard]] LIBBNDL_EXPORT MagicNumber GetMagicNumber () const ;
521+ [[nodiscard]] LIBBNDL_EXPORT uint16_t GetVersion () const ;
522+ [[nodiscard]] LIBBNDL_EXPORT Platform GetPlatform () const ;
523+ [[nodiscard]] LIBBNDL_EXPORT Flags GetFlags () const ;
519524
520- LIBBNDL_EXPORT [[nodiscard]] bool IsBurnoutEra () const ;
521- LIBBNDL_EXPORT [[nodiscard]] bool IsNeedForSpeedEra () const ;
525+ [[nodiscard]] LIBBNDL_EXPORT bool IsBurnoutEra () const ;
526+ [[nodiscard]] LIBBNDL_EXPORT bool IsNeedForSpeedEra () const ;
522527
523- LIBBNDL_EXPORT [[nodiscard]] std::optional<ResourceDebugInfo> GetResourceDebugInfo (const std::string &resourceName) const ;
524- LIBBNDL_EXPORT [[nodiscard]] std::optional<ResourceDebugInfo> GetResourceDebugInfo (ResourceID resourceID) const ;
525- LIBBNDL_EXPORT [[nodiscard]] std::optional<uint32_t > GetResourceType (const std::string &resourceName) const ;
526- LIBBNDL_EXPORT [[nodiscard]] std::optional<uint32_t > GetResourceType (ResourceID resourceID) const ;
527- LIBBNDL_EXPORT [[nodiscard]] std::optional<Resource> GetResource (const std::string &resourceName) const ;
528- LIBBNDL_EXPORT [[nodiscard]] std::optional<Resource> GetResource (ResourceID resourceID) const ;
529- LIBBNDL_EXPORT [[nodiscard]] Buffer GetBinary (const std::string &resourceName, MemoryType memoryType) const ;
530- LIBBNDL_EXPORT [[nodiscard]] Buffer GetBinary (ResourceID resourceID, MemoryType memoryType) const ;
528+ [[nodiscard]] LIBBNDL_EXPORT std::optional<ResourceDebugInfo> GetResourceDebugInfo (const std::string &resourceName, uint8_t streamIndex = 0 ) const ;
529+ [[nodiscard]] LIBBNDL_EXPORT std::optional<ResourceDebugInfo> GetResourceDebugInfo (ResourceID resourceID, uint8_t streamIndex = 0 ) const ;
530+ [[nodiscard]] LIBBNDL_EXPORT std::optional<uint32_t > GetResourceType (const std::string &resourceName, uint8_t streamIndex = 0 ) const ;
531+ [[nodiscard]] LIBBNDL_EXPORT std::optional<uint32_t > GetResourceType (ResourceID resourceID, uint8_t streamIndex = 0 ) const ;
532+ [[nodiscard]] LIBBNDL_EXPORT std::optional<Resource> GetResource (const std::string &resourceName, uint8_t streamIndex = 0 ) const ;
533+ [[nodiscard]] LIBBNDL_EXPORT std::optional<Resource> GetResource (ResourceID resourceID, uint8_t streamIndex = 0 ) const ;
534+ [[nodiscard]] LIBBNDL_EXPORT Buffer GetBinary (const std::string &resourceName, MemoryType memoryType, uint8_t streamIndex = 0 ) const ;
535+ [[nodiscard]] LIBBNDL_EXPORT Buffer GetBinary (ResourceID resourceID, MemoryType memoryType, uint8_t streamIndex = 0 ) const ;
531536
532- LIBBNDL_EXPORT bool AddResource (const std::string &resourceName, const Resource &data, uint32_t resourceType);
533- LIBBNDL_EXPORT bool AddResource (ResourceID resourceID, const Resource &data, uint32_t resourceType);
534- LIBBNDL_EXPORT bool AddResourceDebugInfo (const std::string &resourceName, const std::string &name, const std::string &type);
535- LIBBNDL_EXPORT bool AddResourceDebugInfo (ResourceID resourceID, const std::string &name, const std::string &type);
537+ LIBBNDL_EXPORT bool AddResource (const std::string &resourceName, const Resource &data, uint32_t resourceType, uint8_t streamIndex = 0 );
538+ LIBBNDL_EXPORT bool AddResource (ResourceID resourceID, const Resource &data, uint32_t resourceType, uint8_t streamIndex = 0 );
539+ LIBBNDL_EXPORT bool AddResourceDebugInfo (const std::string &resourceName, const std::string &name, const std::string &type, uint8_t streamIndex = 0 );
540+ LIBBNDL_EXPORT bool AddResourceDebugInfo (ResourceID resourceID, const std::string &name, const std::string &type, uint8_t streamIndex = 0 );
536541
537- LIBBNDL_EXPORT bool ReplaceResource (const std::string &resourceName, const Resource &data);
538- LIBBNDL_EXPORT bool ReplaceResource (ResourceID resourceID, const Resource &data);
542+ LIBBNDL_EXPORT bool ReplaceResource (const std::string &resourceName, const Resource &data, uint8_t streamIndex = 0 );
543+ LIBBNDL_EXPORT bool ReplaceResource (ResourceID resourceID, const Resource &data, uint8_t streamIndex = 0 );
539544
540- LIBBNDL_EXPORT [[nodiscard]] std::vector<ResourceID> GetResourceIDs () const ;
541- LIBBNDL_EXPORT [[nodiscard]] std::map<uint32_t , std::vector<ResourceID>> GetResourceIDsByType () const ;
545+ [[nodiscard]] LIBBNDL_EXPORT std::vector<ResourceID> GetResourceIDs () const ;
546+ [[nodiscard]] LIBBNDL_EXPORT std::map<uint32_t , std::vector<ResourceID>> GetResourceIDsByType () const ;
547+ [[nodiscard]] LIBBNDL_EXPORT std::vector<uint8_t > GetResourceStreamIndices (ResourceID resourceID) const ;
542548
543- LIBBNDL_EXPORT [[nodiscard]] std::vector<MemoryType> GetMemoryTypes () const ;
549+ [[nodiscard]] LIBBNDL_EXPORT ResourceID GetDefaultResourceID () const ;
550+ [[nodiscard]] LIBBNDL_EXPORT int32_t GetDefaultResourceStreamIndex () const ;
551+ [[nodiscard]] LIBBNDL_EXPORT std::string GetStreamName (uint8_t index) const ;
552+
553+ [[nodiscard]] LIBBNDL_EXPORT std::vector<MemoryType> GetMemoryTypes () const ;
544554
545555 private:
546556 std::unique_ptr<Formats::Base> m_impl;
0 commit comments