mirror of https://github.com/AxioDL/metaforce.git
RetroDataSpec: Make use of make_unique where applicable
Same behavior, but without a mildly wonky way of performing it.
This commit is contained in:
parent
53694481e5
commit
9ef2fbba5a
|
@ -27,11 +27,11 @@ void MAPA::Enumerate<BigDNA::Read>(typename Read::StreamT& __dna_reader) {
|
|||
/* version */
|
||||
version = __dna_reader.readUint32Big();
|
||||
if (version == 2)
|
||||
header.reset(new HeaderMP1);
|
||||
header = std::make_unique<HeaderMP1>();
|
||||
else if (version == 3)
|
||||
header.reset(new HeaderMP2);
|
||||
header = std::make_unique<HeaderMP2>();
|
||||
else if (version == 5)
|
||||
header.reset(new HeaderMP3);
|
||||
header = std::make_unique<HeaderMP3>();
|
||||
else {
|
||||
LogDNACommon.report(logvisor::Error, fmt("invalid MAPA version"));
|
||||
return;
|
||||
|
@ -41,10 +41,11 @@ void MAPA::Enumerate<BigDNA::Read>(typename Read::StreamT& __dna_reader) {
|
|||
|
||||
for (atUint32 i = 0; i < header->mappableObjectCount(); i++) {
|
||||
std::unique_ptr<IMappableObject> mo = nullptr;
|
||||
if (version != 5)
|
||||
mo.reset(new MappableObjectMP1_2);
|
||||
else
|
||||
mo.reset(new MappableObjectMP3);
|
||||
if (version != 5) {
|
||||
mo = std::make_unique<MappableObjectMP1_2>();
|
||||
} else {
|
||||
mo = std::make_unique<MappableObjectMP3>();
|
||||
}
|
||||
mo->read(__dna_reader);
|
||||
mappableObjects.push_back(std::move(mo));
|
||||
}
|
||||
|
|
|
@ -611,30 +611,30 @@ std::string_view ANCS::CharacterSet::CharacterInfo::DNAType() {
|
|||
|
||||
template <>
|
||||
void ANCS::AnimationSet::MetaAnimFactory::Enumerate<BigDNA::Read>(athena::io::IStreamReader& reader) {
|
||||
IMetaAnim::Type type(IMetaAnim::Type(reader.readUint32Big()));
|
||||
const auto type = IMetaAnim::Type(reader.readUint32Big());
|
||||
switch (type) {
|
||||
case IMetaAnim::Type::Primitive:
|
||||
m_anim.reset(new struct MetaAnimPrimitive);
|
||||
m_anim = std::make_unique<MetaAnimPrimitive>();
|
||||
m_anim->read(reader);
|
||||
break;
|
||||
case IMetaAnim::Type::Blend:
|
||||
m_anim.reset(new struct MetaAnimBlend);
|
||||
m_anim = std::make_unique<MetaAnimBlend>();
|
||||
m_anim->read(reader);
|
||||
break;
|
||||
case IMetaAnim::Type::PhaseBlend:
|
||||
m_anim.reset(new struct MetaAnimPhaseBlend);
|
||||
m_anim = std::make_unique<MetaAnimPhaseBlend>();
|
||||
m_anim->read(reader);
|
||||
break;
|
||||
case IMetaAnim::Type::Random:
|
||||
m_anim.reset(new struct MetaAnimRandom);
|
||||
m_anim = std::make_unique<MetaAnimRandom>();
|
||||
m_anim->read(reader);
|
||||
break;
|
||||
case IMetaAnim::Type::Sequence:
|
||||
m_anim.reset(new struct MetaAnimSequence);
|
||||
m_anim = std::make_unique<MetaAnimSequence>();
|
||||
m_anim->read(reader);
|
||||
break;
|
||||
default:
|
||||
m_anim.reset(nullptr);
|
||||
m_anim.reset();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -660,22 +660,22 @@ void ANCS::AnimationSet::MetaAnimFactory::Enumerate<BigDNA::ReadYaml>(athena::io
|
|||
std::string type = reader.readString("type");
|
||||
std::transform(type.begin(), type.end(), type.begin(), tolower);
|
||||
if (type == "primitive") {
|
||||
m_anim.reset(new struct MetaAnimPrimitive);
|
||||
m_anim = std::make_unique<MetaAnimPrimitive>();
|
||||
m_anim->read(reader);
|
||||
} else if (type == "blend") {
|
||||
m_anim.reset(new struct MetaAnimBlend);
|
||||
m_anim = std::make_unique<MetaAnimBlend>();
|
||||
m_anim->read(reader);
|
||||
} else if (type == "phaseblend") {
|
||||
m_anim.reset(new struct MetaAnimPhaseBlend);
|
||||
m_anim = std::make_unique<MetaAnimPhaseBlend>();
|
||||
m_anim->read(reader);
|
||||
} else if (type == "random") {
|
||||
m_anim.reset(new struct MetaAnimRandom);
|
||||
m_anim = std::make_unique<MetaAnimRandom>();
|
||||
m_anim->read(reader);
|
||||
} else if (type == "sequence") {
|
||||
m_anim.reset(new struct MetaAnimSequence);
|
||||
m_anim = std::make_unique<MetaAnimSequence>();
|
||||
m_anim->read(reader);
|
||||
} else {
|
||||
m_anim.reset(nullptr);
|
||||
m_anim.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -696,20 +696,20 @@ void ANCS::AnimationSet::MetaTransFactory::Enumerate<BigDNA::Read>(athena::io::I
|
|||
IMetaTrans::Type type(IMetaTrans::Type(reader.readUint32Big()));
|
||||
switch (type) {
|
||||
case IMetaTrans::Type::MetaAnim:
|
||||
m_trans.reset(new struct MetaTransMetaAnim);
|
||||
m_trans = std::make_unique<MetaTransMetaAnim>();
|
||||
m_trans->read(reader);
|
||||
break;
|
||||
case IMetaTrans::Type::Trans:
|
||||
m_trans.reset(new struct MetaTransTrans);
|
||||
m_trans = std::make_unique<MetaTransTrans>();
|
||||
m_trans->read(reader);
|
||||
break;
|
||||
case IMetaTrans::Type::PhaseTrans:
|
||||
m_trans.reset(new struct MetaTransPhaseTrans);
|
||||
m_trans = std::make_unique<MetaTransPhaseTrans>();
|
||||
m_trans->read(reader);
|
||||
break;
|
||||
case IMetaTrans::Type::NoTrans:
|
||||
default:
|
||||
m_trans.reset(nullptr);
|
||||
m_trans.reset();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -737,16 +737,16 @@ void ANCS::AnimationSet::MetaTransFactory::Enumerate<BigDNA::ReadYaml>(athena::i
|
|||
std::string type = reader.readString("type");
|
||||
std::transform(type.begin(), type.end(), type.begin(), tolower);
|
||||
if (type == "metaanim") {
|
||||
m_trans.reset(new struct MetaTransMetaAnim);
|
||||
m_trans = std::make_unique<MetaTransMetaAnim>();
|
||||
m_trans->read(reader);
|
||||
} else if (type == "trans") {
|
||||
m_trans.reset(new struct MetaTransTrans);
|
||||
m_trans = std::make_unique<MetaTransTrans>();
|
||||
m_trans->read(reader);
|
||||
} else if (type == "phasetrans") {
|
||||
m_trans.reset(new struct MetaTransPhaseTrans);
|
||||
m_trans = std::make_unique<MetaTransPhaseTrans>();
|
||||
m_trans->read(reader);
|
||||
} else {
|
||||
m_trans.reset(nullptr);
|
||||
m_trans.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -122,15 +122,15 @@ void ANIM::Enumerate<BigDNA::Read>(typename Read::StreamT& reader) {
|
|||
atUint32 version = reader.readUint32Big();
|
||||
switch (version) {
|
||||
case 0:
|
||||
m_anim.reset(new struct ANIM0);
|
||||
m_anim = std::make_unique<ANIM0>();
|
||||
m_anim->read(reader);
|
||||
break;
|
||||
case 2:
|
||||
m_anim.reset(new struct ANIM2(false));
|
||||
m_anim = std::make_unique<ANIM2>(false);
|
||||
m_anim->read(reader);
|
||||
break;
|
||||
case 3:
|
||||
m_anim.reset(new struct ANIM2(true));
|
||||
m_anim = std::make_unique<ANIM2>(true);
|
||||
m_anim->read(reader);
|
||||
break;
|
||||
default:
|
||||
|
@ -548,7 +548,7 @@ void ANIM::ANIM2::Enumerate<BigDNA::BinarySize>(size_t& __isz) {
|
|||
|
||||
ANIM::ANIM(const BlenderAction& act, const std::unordered_map<std::string, atInt32>& idMap,
|
||||
const DNAANIM::RigInverter<CINF>& rig, bool pc) {
|
||||
m_anim.reset(new struct ANIM2(pc));
|
||||
m_anim = std::make_unique<ANIM2>(pc);
|
||||
IANIM& newAnim = *m_anim;
|
||||
newAnim.looping = act.looping;
|
||||
|
||||
|
|
|
@ -99,15 +99,18 @@ void DCLN::Collision::Node::Enumerate(typename Op::StreamT& s) {
|
|||
Do<Op>(athena::io::PropId{"halfExtent"}, halfExtent, s);
|
||||
Do<Op>(athena::io::PropId{"isLeaf"}, isLeaf, s);
|
||||
if (isLeaf) {
|
||||
if (!leafData)
|
||||
leafData.reset(new LeafData);
|
||||
if (!leafData) {
|
||||
leafData = std::make_unique<LeafData>();
|
||||
}
|
||||
Do<Op>(athena::io::PropId{"leafData"}, *leafData, s);
|
||||
} else {
|
||||
if (!left)
|
||||
left.reset(new Node);
|
||||
if (!left) {
|
||||
left = std::make_unique<Node>();
|
||||
}
|
||||
Do<Op>(athena::io::PropId{"left"}, *left, s);
|
||||
if (!right)
|
||||
right.reset(new Node);
|
||||
if (!right) {
|
||||
right = std::make_unique<Node>();
|
||||
}
|
||||
Do<Op>(athena::io::PropId{"right"}, *right, s);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,43 +54,43 @@ void FRME::Widget::Enumerate<BigDNA::Read>(athena::io::IStreamReader& __dna_read
|
|||
header.read(__dna_reader);
|
||||
switch (type.toUint32()) {
|
||||
case SBIG('BWIG'):
|
||||
widgetInfo.reset(new BWIGInfo);
|
||||
widgetInfo = std::make_unique<BWIGInfo>();
|
||||
break;
|
||||
case SBIG('HWIG'):
|
||||
widgetInfo.reset(new HWIGInfo);
|
||||
widgetInfo = std::make_unique<HWIGInfo>();
|
||||
break;
|
||||
case SBIG('CAMR'):
|
||||
widgetInfo.reset(new CAMRInfo);
|
||||
widgetInfo = std::make_unique<CAMRInfo>();
|
||||
break;
|
||||
case SBIG('LITE'):
|
||||
widgetInfo.reset(new LITEInfo);
|
||||
widgetInfo = std::make_unique<LITEInfo>();
|
||||
break;
|
||||
case SBIG('ENRG'):
|
||||
widgetInfo.reset(new ENRGInfo);
|
||||
widgetInfo = std::make_unique<ENRGInfo>();
|
||||
break;
|
||||
case SBIG('MODL'):
|
||||
widgetInfo.reset(new MODLInfo);
|
||||
widgetInfo = std::make_unique<MODLInfo>();
|
||||
break;
|
||||
case SBIG('METR'):
|
||||
widgetInfo.reset(new METRInfo);
|
||||
widgetInfo = std::make_unique<METRInfo>();
|
||||
break;
|
||||
case SBIG('GRUP'):
|
||||
widgetInfo.reset(new GRUPInfo);
|
||||
widgetInfo = std::make_unique<GRUPInfo>();
|
||||
break;
|
||||
case SBIG('PANE'):
|
||||
widgetInfo.reset(new PANEInfo);
|
||||
widgetInfo = std::make_unique<PANEInfo>();
|
||||
break;
|
||||
case SBIG('TXPN'):
|
||||
widgetInfo.reset(new TXPNInfo(owner->version));
|
||||
widgetInfo = std::make_unique<TXPNInfo>(owner->version);
|
||||
break;
|
||||
case SBIG('IMGP'):
|
||||
widgetInfo.reset(new IMGPInfo);
|
||||
widgetInfo = std::make_unique<IMGPInfo>();
|
||||
break;
|
||||
case SBIG('TBGP'):
|
||||
widgetInfo.reset(new TBGPInfo);
|
||||
widgetInfo = std::make_unique<TBGPInfo>();
|
||||
break;
|
||||
case SBIG('SLGP'):
|
||||
widgetInfo.reset(new SLGPInfo);
|
||||
widgetInfo = std::make_unique<SLGPInfo>();
|
||||
break;
|
||||
default:
|
||||
Log.report(logvisor::Fatal, fmt(_SYS_STR("Unsupported FRME widget type {}")), type);
|
||||
|
@ -169,12 +169,13 @@ void FRME::Widget::Enumerate<BigDNA::BinarySize>(size_t& __isz) {
|
|||
template <>
|
||||
void FRME::Widget::CAMRInfo::Enumerate<BigDNA::Read>(athena::io::IStreamReader& __dna_reader) {
|
||||
projectionType = ProjectionType(__dna_reader.readUint32Big());
|
||||
if (projectionType == ProjectionType::Perspective)
|
||||
projection.reset(new PerspectiveProjection);
|
||||
else if (projectionType == ProjectionType::Orthographic)
|
||||
projection.reset(new OrthographicProjection);
|
||||
else
|
||||
if (projectionType == ProjectionType::Perspective) {
|
||||
projection = std::make_unique<PerspectiveProjection>();
|
||||
} else if (projectionType == ProjectionType::Orthographic) {
|
||||
projection = std::make_unique<OrthographicProjection>();
|
||||
} else {
|
||||
Log.report(logvisor::Fatal, fmt(_SYS_STR("Invalid CAMR projection mode! {}")), int(projectionType));
|
||||
}
|
||||
|
||||
projection->read(__dna_reader);
|
||||
}
|
||||
|
|
|
@ -126,11 +126,11 @@ void ANIM::Enumerate<BigDNA::Read>(typename Read::StreamT& reader) {
|
|||
atUint32 version = reader.readUint32Big();
|
||||
switch (version) {
|
||||
case 0:
|
||||
m_anim.reset(new struct ANIM0);
|
||||
m_anim = std::make_unique<ANIM0>();
|
||||
m_anim->read(reader);
|
||||
break;
|
||||
case 2:
|
||||
m_anim.reset(new struct ANIM2);
|
||||
m_anim = std::make_unique<ANIM2>();
|
||||
m_anim->read(reader);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -130,11 +130,11 @@ void ANIM::Enumerate<BigDNA::Read>(typename Read::StreamT& reader) {
|
|||
atUint32 version = reader.readUint32Big();
|
||||
switch (version) {
|
||||
case 0:
|
||||
m_anim.reset(new struct ANIM0);
|
||||
m_anim = std::make_unique<ANIM0>();
|
||||
m_anim->read(reader);
|
||||
break;
|
||||
case 1:
|
||||
m_anim.reset(new struct ANIM1);
|
||||
m_anim = std::make_unique<ANIM1>();
|
||||
m_anim->read(reader);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -74,30 +74,30 @@ std::string_view CHAR::AnimationInfo::EVNT::SFXEvent::DNAType() {
|
|||
|
||||
template <>
|
||||
void CHAR::AnimationInfo::MetaAnimFactory::Enumerate<BigDNA::Read>(athena::io::IStreamReader& reader) {
|
||||
IMetaAnim::Type type(IMetaAnim::Type(reader.readUint32Big()));
|
||||
const auto type = IMetaAnim::Type(reader.readUint32Big());
|
||||
switch (type) {
|
||||
case IMetaAnim::Type::Primitive:
|
||||
m_anim.reset(new struct MetaAnimPrimitive);
|
||||
m_anim = std::make_unique<MetaAnimPrimitive>();
|
||||
m_anim->read(reader);
|
||||
break;
|
||||
case IMetaAnim::Type::Blend:
|
||||
m_anim.reset(new struct MetaAnimBlend);
|
||||
m_anim = std::make_unique<MetaAnimBlend>();
|
||||
m_anim->read(reader);
|
||||
break;
|
||||
case IMetaAnim::Type::PhaseBlend:
|
||||
m_anim.reset(new struct MetaAnimPhaseBlend);
|
||||
m_anim = std::make_unique<MetaAnimPhaseBlend>();
|
||||
m_anim->read(reader);
|
||||
break;
|
||||
case IMetaAnim::Type::Random:
|
||||
m_anim.reset(new struct MetaAnimRandom);
|
||||
m_anim = std::make_unique<MetaAnimRandom>();
|
||||
m_anim->read(reader);
|
||||
break;
|
||||
case IMetaAnim::Type::Sequence:
|
||||
m_anim.reset(new struct MetaAnimSequence);
|
||||
m_anim = std::make_unique<MetaAnimSequence>();
|
||||
m_anim->read(reader);
|
||||
break;
|
||||
default:
|
||||
m_anim.reset(nullptr);
|
||||
m_anim.reset();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -123,22 +123,22 @@ void CHAR::AnimationInfo::MetaAnimFactory::Enumerate<BigDNA::ReadYaml>(athena::i
|
|||
std::string type = reader.readString("type");
|
||||
std::transform(type.begin(), type.end(), type.begin(), tolower);
|
||||
if (type == "primitive") {
|
||||
m_anim.reset(new struct MetaAnimPrimitive);
|
||||
m_anim = std::make_unique<MetaAnimPrimitive>();
|
||||
m_anim->read(reader);
|
||||
} else if (type == "blend") {
|
||||
m_anim.reset(new struct MetaAnimBlend);
|
||||
m_anim = std::make_unique<MetaAnimBlend>();
|
||||
m_anim->read(reader);
|
||||
} else if (type == "phaseblend") {
|
||||
m_anim.reset(new struct MetaAnimPhaseBlend);
|
||||
m_anim = std::make_unique<MetaAnimPhaseBlend>();
|
||||
m_anim->read(reader);
|
||||
} else if (type == "random") {
|
||||
m_anim.reset(new struct MetaAnimRandom);
|
||||
m_anim = std::make_unique<MetaAnimRandom>();
|
||||
m_anim->read(reader);
|
||||
} else if (type == "sequence") {
|
||||
m_anim.reset(new struct MetaAnimSequence);
|
||||
m_anim = std::make_unique<MetaAnimSequence>();
|
||||
m_anim->read(reader);
|
||||
} else {
|
||||
m_anim.reset(nullptr);
|
||||
m_anim.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,19 +12,19 @@ void MaterialSet::Material::SectionFactory::Enumerate<BigDNA::Read>(typename Rea
|
|||
type.read(reader);
|
||||
switch (ISection::Type(type.toUint32())) {
|
||||
case ISection::Type::PASS:
|
||||
section.reset(new struct SectionPASS);
|
||||
section = std::make_unique<SectionPASS>();
|
||||
section->read(reader);
|
||||
break;
|
||||
case ISection::Type::CLR:
|
||||
section.reset(new struct SectionCLR);
|
||||
section = std::make_unique<SectionCLR>();
|
||||
section->read(reader);
|
||||
break;
|
||||
case ISection::Type::INT:
|
||||
section.reset(new struct SectionINT);
|
||||
section = std::make_unique<SectionINT>();
|
||||
section->read(reader);
|
||||
break;
|
||||
default:
|
||||
section.reset(nullptr);
|
||||
section.reset();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue