neptools

Modding tools to Neptunia games
git clone https://git.neptards.moe/neptards/neptools.git
Log | Files | Refs | Submodules | README | LICENSE

header.hpp (1834B)


      1 #ifndef UUID_B9D3C4DA_158C_4858_903C_9EBDD92C2CBC
      2 #define UUID_B9D3C4DA_158C_4858_903C_9EBDD92C2CBC
      3 #pragma once
      4 
      5 #include "../raw_item.hpp"
      6 #include <libshit/fixed_string.hpp>
      7 #include <boost/endian/arithmetic.hpp>
      8 
      9 namespace Neptools::Stcm
     10 {
     11 
     12   class HeaderItem final : public Item
     13   {
     14     LIBSHIT_DYNAMIC_OBJECT;
     15   public:
     16     using MsgType = Libshit::FixedString<0x20-5-1>;
     17     struct Header
     18     {
     19       char magic[5];
     20       char endian;
     21       MsgType msg;
     22 
     23       boost::endian::little_uint32_t export_offset;
     24       boost::endian::little_uint32_t export_count;
     25       boost::endian::little_uint32_t field_28;
     26       boost::endian::little_uint32_t collection_link_offset;
     27       boost::endian::little_uint32_t field_30;
     28       boost::endian::little_uint32_t expansion_offset;
     29       boost::endian::little_uint32_t expansion_count;
     30 
     31       void Validate(FilePosition file_size) const;
     32     };
     33     static_assert(sizeof(Header) == 0x3c);
     34 
     35     HeaderItem(
     36       Key k, Context& ctx, const MsgType& msg,
     37       Libshit::NotNull<LabelPtr> export_sec,
     38       Libshit::NotNull<LabelPtr> collection_link, uint32_t field_28,
     39       LabelPtr expansion)
     40       : Item{k, ctx}, msg{msg}, export_sec{Libshit::Move(export_sec)},
     41         collection_link{Libshit::Move(collection_link)},
     42         expansion{Libshit::Move(expansion)},field_28{field_28} {}
     43     LIBSHIT_NOLUA
     44     HeaderItem(Key k, Context& ctx, const Header& hdr);
     45     static HeaderItem& CreateAndInsert(ItemPointer ptr);
     46 
     47     FilePosition GetSize() const noexcept override { return sizeof(Header); }
     48 
     49     MsgType msg;
     50     Libshit::NotNull<LabelPtr> export_sec;
     51     Libshit::NotNull<LabelPtr> collection_link;
     52     LabelPtr expansion;
     53     uint32_t field_28;
     54 
     55   private:
     56     void Dump_(Sink& sink) const override;
     57     void Inspect_(std::ostream& os, unsigned indent) const override;
     58   };
     59 
     60 }
     61 #endif