Update sead and fix sead::Buffer::tryAllocBuffer issues

This commit is contained in:
Léo Lam
2021-04-08 02:18:15 +02:00
parent 5adfee548a
commit 2364c80231
4 changed files with 7 additions and 22 deletions
@@ -16,11 +16,6 @@ BoneControl::~BoneControl() {
void BoneControl::doCreate_(u8* buffer, u32 buffer_size, sead::Heap* heap) {}
bool allocBoneGroups(sead::Buffer<BoneControl::BoneGroup>& buffer, int size, sead::Heap* heap,
int align = sizeof(void*)) {
return buffer.tryAllocBuffer(size, heap, align);
}
// NON_MATCHING: mFootIkController.isInvalidFt (???)
bool BoneControl::parse_(u8* data, size_t size, sead::Heap* heap) {
if (!data)
@@ -185,7 +180,7 @@ bool BoneControl::parse_(u8* data, size_t size, sead::Heap* heap) {
const auto bone_groups = agl::utl::getResParameterList(root, "BoneGroups");
if (bone_groups.ptr() && bone_groups.getResParameterListNum() != 0) {
if (!allocBoneGroups(mBoneGroups, bone_groups.getResParameterListNum(), heap))
if (!mBoneGroups.tryAllocBuffer(bone_groups.getResParameterListNum(), heap))
return false;
sead::FixedSafeString<32> bone_group_name{"BoneGroup_"};
@@ -104,13 +104,8 @@ bool ModelList::parse_(u8* data, size_t size, sead::Heap* heap) {
return true;
}
bool allocModelDataBuffer(sead::Buffer<ModelList::ModelData>& buffer, int size, sead::Heap* heap,
int alignment = sizeof(void*)) {
return buffer.tryAllocBuffer(size, heap, alignment);
}
bool ModelList::parseModelData(const agl::utl::ResParameterList& res, sead::Heap* heap) {
if (!allocModelDataBuffer(mModelData, res.getResParameterListNum() != 0, heap))
if (!mModelData.tryAllocBuffer(res.getResParameterListNum() != 0, heap))
return false;
sead::FixedSafeString<32> list_name{str_ModelData};
@@ -154,11 +149,6 @@ bool ModelList::parseModelData(const agl::utl::ResParameterList& res, sead::Heap
return true;
}
bool allocAnmTargetPartialBuffer(sead::Buffer<ModelList::Partial>& buffer, int size,
sead::Heap* heap, int alignment = sizeof(void*)) {
return buffer.tryAllocBuffer(size, heap, alignment);
}
bool ModelList::parseAnmTarget(const agl::utl::ResParameterList& res, sead::Heap* heap) {
if (!mAnmTargets.tryAllocBuffer(std::min<u32>(res.getResParameterListNum(), NumUnitMax), heap))
return false;
@@ -180,7 +170,7 @@ bool ModelList::parseAnmTarget(const agl::utl::ResParameterList& res, sead::Heap
const auto partials =
agl::utl::getResParameterList(res.getResParameterList(it.getIndex()), str_Partial);
if (partials.ptr() && partials.getResParameterObjNum() != 0) {
if (!allocAnmTargetPartialBuffer(it->partials, partials.getResParameterObjNum(), heap))
if (!it->partials.tryAllocBuffer(partials.getResParameterObjNum(), heap))
return false;
sead::FixedSafeString<32> partial_name{str_Partial};