gbnl.cpp (1082B)
1 #include "gbnl.hpp" 2 #include "data.hpp" 3 #include "../context.hpp" 4 #include "../gbnl_lua.hpp" 5 #include "../raw_item.hpp" 6 7 #include <libshit/container/vector.lua.hpp> 8 9 namespace Neptools::Stcm 10 { 11 12 void GbnlItem::Dispose() noexcept 13 { 14 if (auto ctx = GetContextMaybe()) 15 if (auto file = ctx.DynamicPointerCast<File>()) 16 file->UnsetGbnl(*this); 17 Item::Dispose(); 18 } 19 20 GbnlItem& GbnlItem::CreateAndInsert(ItemPointer ptr) 21 { 22 auto x = RawItem::GetSource(ptr, -1); 23 return x.ritem.SplitCreate<GbnlItem>(ptr.offset, x.src); 24 } 25 26 static DataFactory factory{[](DataItem& it) 27 { 28 auto child = dynamic_cast<RawItem*>(&it.GetChildren().front()); 29 if (child && child->GetSize() > sizeof(Gbnl::Header)) 30 { 31 char buf[4]; 32 child->GetSource().Pread(child->GetSize() - sizeof(Gbnl::Header), buf, 4); 33 if (memcmp(buf, "GBNL", 4) == 0) 34 { 35 GbnlItem::CreateAndInsert({child, 0}); 36 return true; 37 } 38 } 39 return false; 40 }}; 41 42 } 43 44 LIBSHIT_STD_VECTOR_FWD(gbnl_struct, Neptools::Gbnl::StructPtr); 45 #include "gbnl.binding.hpp"