From 14e0468adf44b3f12b15ed4f4131be055bd1ef6c Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Tue, 12 Apr 2016 04:37:07 -0700 Subject: [PATCH] DGRP Fixes --- DataSpec/DNACommon/DGRP.cpp | 4 +++- DataSpec/DNACommon/DGRP.hpp | 33 ++++++++++++++++++++++++++++ DataSpec/DNAMP1/DNAMP1.cpp | 2 +- DataSpec/DNAMP2/DNAMP2.cpp | 2 +- DataSpec/DNAMP3/DNAMP3.cpp | 2 +- DataSpec/SpecMP1.cpp | 9 ++++++++ Editor/ProjectResourceFactoryMP1.cpp | 8 ++++++- Runtime/CDependencyGroup.cpp | 24 ++++++++++++++++++++ Runtime/CDependencyGroup.hpp | 19 ++++++++++++++++ Runtime/CMakeLists.txt | 1 + 10 files changed, 99 insertions(+), 5 deletions(-) create mode 100644 DataSpec/DNACommon/DGRP.hpp create mode 100644 Runtime/CDependencyGroup.cpp create mode 100644 Runtime/CDependencyGroup.hpp diff --git a/DataSpec/DNACommon/DGRP.cpp b/DataSpec/DNACommon/DGRP.cpp index cb216f3d9..7b558e320 100644 --- a/DataSpec/DNACommon/DGRP.cpp +++ b/DataSpec/DNACommon/DGRP.cpp @@ -5,6 +5,8 @@ namespace DataSpec { +namespace DNADGRP +{ template void DGRP::read(athena::io::IStreamReader& __dna_reader) { @@ -137,5 +139,5 @@ bool WriteDGRP(const DGRP& dgrp, const hecl::ProjectPath& outPath) } template bool WriteDGRP(const DGRP& dgrp, const hecl::ProjectPath& outPath); template bool WriteDGRP(const DGRP& dgrp, const hecl::ProjectPath& outPath); - +} } diff --git a/DataSpec/DNACommon/DGRP.hpp b/DataSpec/DNACommon/DGRP.hpp new file mode 100644 index 000000000..6d321ffd9 --- /dev/null +++ b/DataSpec/DNACommon/DGRP.hpp @@ -0,0 +1,33 @@ +#ifndef __COMMON_DGRP_HPP__ +#define __COMMON_DGRP_HPP__ + +#include "DNACommon.hpp" +#include "PAK.hpp" + +namespace DataSpec +{ +namespace DNADGRP +{ +template +struct DGRP : BigYAML +{ + DECL_YAML + Value dependCount; + struct ObjectTag : BigYAML + { + DECL_YAML + DNAFourCC type; + UniqueID32 id; + }; + + Vector depends; +}; + + +template +bool ExtractDGRP(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath); +template +bool WriteDGRP(const DGRP& dgrp, const hecl::ProjectPath& outPath); +} +} +#endif // __COMMON_DGRP_HPP__ diff --git a/DataSpec/DNAMP1/DNAMP1.cpp b/DataSpec/DNAMP1/DNAMP1.cpp index 19d6943b5..15c239c5a 100644 --- a/DataSpec/DNAMP1/DNAMP1.cpp +++ b/DataSpec/DNAMP1/DNAMP1.cpp @@ -308,7 +308,7 @@ ResExtractor PAKBridge::LookupExtractor(const PAK::Entry& entry) case SBIG('FONT'): return {DNAFont::ExtractFONT, nullptr, {_S(".yaml")}}; case SBIG('DGRP'): - return {ExtractDGRP, nullptr, {_S(".yaml")}}; + return {DNADGRP::ExtractDGRP, nullptr, {_S(".yaml")}}; } return {}; } diff --git a/DataSpec/DNAMP2/DNAMP2.cpp b/DataSpec/DNAMP2/DNAMP2.cpp index acc204c10..b81a59256 100644 --- a/DataSpec/DNAMP2/DNAMP2.cpp +++ b/DataSpec/DNAMP2/DNAMP2.cpp @@ -237,7 +237,7 @@ ResExtractor PAKBridge::LookupExtractor(const DNAMP1::PAK::Entry& ent case SBIG('FONT'): return {DNAFont::ExtractFONT, nullptr, {_S(".yaml")}}; case SBIG('DGRP'): - return {ExtractDGRP, nullptr, {_S(".yaml")}}; + return {DNADGRP::ExtractDGRP, nullptr, {_S(".yaml")}}; } return {}; } diff --git a/DataSpec/DNAMP3/DNAMP3.cpp b/DataSpec/DNAMP3/DNAMP3.cpp index 8f811b0a2..533c1f5a7 100644 --- a/DataSpec/DNAMP3/DNAMP3.cpp +++ b/DataSpec/DNAMP3/DNAMP3.cpp @@ -245,7 +245,7 @@ ResExtractor PAKBridge::LookupExtractor(const PAK::Entry& entry) case SBIG('FONT'): return {DNAFont::ExtractFONT, nullptr, {_S(".yaml")}}; case SBIG('DGRP'): - return {ExtractDGRP, nullptr, {_S(".yaml")}}; + return {DNADGRP::ExtractDGRP, nullptr, {_S(".yaml")}}; } return {}; } diff --git a/DataSpec/SpecMP1.cpp b/DataSpec/SpecMP1.cpp index 29e4bf547..4a514ddf5 100644 --- a/DataSpec/SpecMP1.cpp +++ b/DataSpec/SpecMP1.cpp @@ -15,6 +15,7 @@ #include "DNACommon/WPSC.hpp" #include "DNACommon/CRSC.hpp" #include "DNACommon/DPSC.hpp" +#include "DNACommon/DGRP.hpp" #include "hecl/ClientProcess.hpp" @@ -339,6 +340,8 @@ struct SpecMP1 : SpecBase return true; else if (!strcmp(classType, DNAParticle::DPSM::DNAType())) return true; + else if (!strcmp(classType, DNADGRP::DGRP::DNAType())) + return true; return false; }); } @@ -436,6 +439,12 @@ struct SpecMP1 : SpecBase dpsm.read(reader); DNAParticle::WriteDPSM(dpsm, out); } + else if (!classStr.compare(DNADGRP::DGRP::DNAType())) + { + DNADGRP::DGRP dgrp; + dgrp.read(reader); + DNADGRP::WriteDGRP(dgrp, out); + } } progress(_S("Done")); } diff --git a/Editor/ProjectResourceFactoryMP1.cpp b/Editor/ProjectResourceFactoryMP1.cpp index a92559313..468e58f0b 100644 --- a/Editor/ProjectResourceFactoryMP1.cpp +++ b/Editor/ProjectResourceFactoryMP1.cpp @@ -13,7 +13,7 @@ #include "Runtime/Character/CAnimCharacterSet.hpp" #include "Runtime/Character/CAllFormatsAnimSource.hpp" #include "Runtime/Character/CAnimPOIData.hpp" - +#include "Runtime/CDependencyGroup.hpp" #include "DataSpec/DNACommon/TXTR.hpp" namespace DataSpec @@ -37,6 +37,7 @@ ProjectResourceFactoryMP1::ProjectResourceFactoryMP1(hecl::ClientProcess& client m_factoryMgr.AddFactory(FOURCC('ANCS'), FFactoryFunc(FAnimCharacterSet)); m_factoryMgr.AddFactory(FOURCC('ANIM'), FFactoryFunc(AnimSourceFactory)); m_factoryMgr.AddFactory(FOURCC('EVNT'), FFactoryFunc(AnimPOIDataFactory)); + m_factoryMgr.AddFactory(FOURCC('DGRP'), FFactoryFunc(FDependencyGroupFactory)); } void ProjectResourceFactoryMP1::IndexMP1Resources(hecl::Database::Project& proj) @@ -111,6 +112,11 @@ SObjectTag ProjectResourceFactoryMP1::TagFromPath(const hecl::ProjectPath& path, resTag.type = SBIG('EVNT'); return true; } + else if (!strcmp(className, "urde::DGRP")) + { + resTag.type = SBIG('DGRP'); + return true; + } return false; })) { diff --git a/Runtime/CDependencyGroup.cpp b/Runtime/CDependencyGroup.cpp new file mode 100644 index 000000000..ce5825f12 --- /dev/null +++ b/Runtime/CDependencyGroup.cpp @@ -0,0 +1,24 @@ +#include "CDependencyGroup.hpp" +#include "CToken.hpp" + +namespace urde +{ +CDependencyGroup::CDependencyGroup(CInputStream& in) +{ + ReadFromStream(in); +} + +void CDependencyGroup::ReadFromStream(CInputStream& in) +{ + u32 depCount = in.readUint32Big(); + x0_objectTags.reserve(depCount); + for (u32 i = 0 ; i < depCount ; i++) + x0_objectTags.emplace_back(in); +} + +CFactoryFnReturn FDependencyGroupFactory(const SObjectTag& /*tag*/, CInputStream& in, const CVParamTransfer& /*param*/) +{ + return TToken::GetIObjObjectFor(std::unique_ptr(new CDependencyGroup(in))); +} + +} diff --git a/Runtime/CDependencyGroup.hpp b/Runtime/CDependencyGroup.hpp new file mode 100644 index 000000000..7eb88c881 --- /dev/null +++ b/Runtime/CDependencyGroup.hpp @@ -0,0 +1,19 @@ +#ifndef CDEPENDENCYGROUP_HPP +#define CDEPENDENCYGROUP_HPP + +#include "CFactoryMgr.hpp" + +namespace urde +{ +class CDependencyGroup +{ + std::vector x0_objectTags; +public: + CDependencyGroup(CInputStream& in); + void ReadFromStream(CInputStream& in); +}; + +CFactoryFnReturn FDependencyGroupFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& param); +} + +#endif // CDEPENDENCYGROUP_HPP diff --git a/Runtime/CMakeLists.txt b/Runtime/CMakeLists.txt index e0cbead93..c0fc38eac 100644 --- a/Runtime/CMakeLists.txt +++ b/Runtime/CMakeLists.txt @@ -22,6 +22,7 @@ add_library(RuntimeCommon IAllocator.hpp IAllocator.cpp CGameAllocator.hpp CGameAllocator.cpp CPathFindArea.hpp CPathFindArea.cpp + CDependencyGroup.hpp CDependencyGroup.cpp CBasics.hpp CBasicsPC.cpp CIOWin.hpp CIOWinManager.hpp CIOWinManager.cpp