Add DGRP DNA

ScriptMailbox fix
This commit is contained in:
Phillip Stephens 2016-04-12 03:52:40 -07:00
parent adda48a1bf
commit e9abb7abc7
6 changed files with 152 additions and 1 deletions

View File

@ -25,6 +25,7 @@ add_library(DNACommon
DPSC.hpp DPSC.cpp
ParticleCommon.cpp
FONT.hpp FONT.cpp
DGRP.hpp DGRP.cpp
DeafBabe.hpp
BabeDead.hpp
RigInverter.hpp RigInverter.cpp

141
DataSpec/DNACommon/DGRP.cpp Normal file
View File

@ -0,0 +1,141 @@
#include "athena/IStreamReader.hpp"
#include "athena/IStreamWriter.hpp"
#include "athena/FileWriter.hpp"
#include "DGRP.hpp"
namespace DataSpec
{
template <class IDType>
void DGRP<IDType>::read(athena::io::IStreamReader& __dna_reader)
{
/* dependCount */
dependCount = __dna_reader.readUint32Big();
/* depends */
__dna_reader.enumerate(depends, dependCount);
}
template <class IDType>
void DGRP<IDType>::write(athena::io::IStreamWriter& __dna_writer) const
{
/* dependCount */
__dna_writer.writeUint32Big(dependCount);
/* depends */
__dna_writer.enumerate(depends);
}
template <class IDType>
void DGRP<IDType>::read(athena::io::YAMLDocReader& __dna_docin)
{
/* dependCount squelched */
/* depends */
dependCount = __dna_docin.enumerate("depends", depends);
}
template <class IDType>
void DGRP<IDType>::write(athena::io::YAMLDocWriter& __dna_docout) const
{
/* dependCount squelched */
/* depends */
__dna_docout.enumerate("depends", depends);
}
template <class IDType>
const char* DGRP<IDType>::DNAType()
{
return "urde::DGRP";
}
template <class IDType>
size_t DGRP<IDType>::binarySize(size_t __isz) const
{
__isz = __EnumerateSize(__isz, depends);
return __isz + 4;
}
template <class IDType>
void DGRP<IDType>::ObjectTag::read(athena::io::IStreamReader& __dna_reader)
{
/* type */
type.read(__dna_reader);
/* id */
id.read(__dna_reader);
}
template <class IDType>
void DGRP<IDType>::ObjectTag::write(athena::io::IStreamWriter& __dna_writer) const
{
/* type */
type.write(__dna_writer);
/* id */
id.write(__dna_writer);
}
template <class IDType>
void DGRP<IDType>::ObjectTag::read(athena::io::YAMLDocReader& __dna_docin)
{
/* type */
__dna_docin.enumerate("type", type);
/* id */
__dna_docin.enumerate("id", id);
}
template <class IDType>
void DGRP<IDType>::ObjectTag::write(athena::io::YAMLDocWriter& __dna_docout) const
{
/* type */
__dna_docout.enumerate("type", type);
/* id */
__dna_docout.enumerate("id", id);
}
template <class IDType>
const char* DGRP<IDType>::ObjectTag::DNAType()
{
return "urde::DGRP::ObjectTag";
}
template <class IDType>
size_t DGRP<IDType>::ObjectTag::binarySize(size_t __isz) const
{
__isz = type.binarySize(__isz);
__isz = id.binarySize(__isz);
return __isz;
}
template struct DGRP<UniqueID32>;
template struct DGRP<UniqueID64>;
template <class IDType>
bool ExtractDGRP(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath)
{
FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("w"));
if (fp)
{
DGRP<IDType> dgrp;
dgrp.read(rs);
dgrp.toYAMLFile(fp);
fclose(fp);
return true;
}
return false;
}
template bool ExtractDGRP<UniqueID32>(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath);
template bool ExtractDGRP<UniqueID64>(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath);
template <class IDType>
bool WriteDGRP(const DGRP<IDType>& dgrp, const hecl::ProjectPath& outPath)
{
athena::io::FileWriter w(outPath.getAbsolutePath(), true, false);
if (w.hasError())
return false;
dgrp.write(w);
int64_t rem = w.position() % 32;
if (rem)
for (int64_t i=0 ; i<32-rem ; ++i)
w.writeBytes((atInt8*)"\xff", 1);
return true;
}
template bool WriteDGRP<UniqueID32>(const DGRP<UniqueID32>& dgrp, const hecl::ProjectPath& outPath);
template bool WriteDGRP<UniqueID64>(const DGRP<UniqueID64>& dgrp, const hecl::ProjectPath& outPath);
}

View File

@ -13,6 +13,7 @@
#include "../DNACommon/WPSC.hpp"
#include "../DNACommon/DPSC.hpp"
#include "../DNACommon/FONT.hpp"
#include "../DNACommon/DGRP.hpp"
#include "CMDL.hpp"
#include "AFSM.hpp"
#include "ANCS.hpp"
@ -306,6 +307,8 @@ ResExtractor<PAKBridge> PAKBridge::LookupExtractor(const PAK::Entry& entry)
return {DNAParticle::ExtractDPSM<UniqueID32>, nullptr, {_S(".dpsm.yaml")}};
case SBIG('FONT'):
return {DNAFont::ExtractFONT<UniqueID32>, nullptr, {_S(".yaml")}};
case SBIG('DGRP'):
return {ExtractDGRP<UniqueID32>, nullptr, {_S(".yaml")}};
}
return {};
}

View File

@ -10,6 +10,7 @@
#include "../DNACommon/FSM2.hpp"
#include "../DNACommon/TXTR.hpp"
#include "../DNACommon/FONT.hpp"
#include "../DNACommon/DGRP.hpp"
namespace DataSpec
{
@ -235,6 +236,8 @@ ResExtractor<PAKBridge> PAKBridge::LookupExtractor(const DNAMP1::PAK::Entry& ent
return {DNAFSM2::ExtractFSM2<UniqueID32>, nullptr, {_S(".yaml")}};
case SBIG('FONT'):
return {DNAFont::ExtractFONT<UniqueID32>, nullptr, {_S(".yaml")}};
case SBIG('DGRP'):
return {ExtractDGRP<UniqueID32>, nullptr, {_S(".yaml")}};
}
return {};
}

View File

@ -11,6 +11,7 @@
#include "../DNACommon/TXTR.hpp"
#include "../DNACommon/FONT.hpp"
#include "../DNACommon/FSM2.hpp"
#include "../DNACommon/DGRP.hpp"
namespace DataSpec
{
@ -243,6 +244,8 @@ ResExtractor<PAKBridge> PAKBridge::LookupExtractor(const PAK::Entry& entry)
return {DNAFSM2::ExtractFSM2<UniqueID64>, nullptr, {_S(".yaml")}};
case SBIG('FONT'):
return {DNAFont::ExtractFONT<UniqueID64>, nullptr, {_S(".yaml")}};
case SBIG('DGRP'):
return {ExtractDGRP<UniqueID64>, nullptr, {_S(".yaml")}};
}
return {};
}

View File

@ -29,7 +29,7 @@ public:
void AddMsg(TEditorId, EScriptObjectMessage, bool);
void RemoveMsg(TEditorId, EScriptObjectMessage, bool);
void SendScriptMsgs(const TAreaId&, CStateManager&);
void SendMsgs(const TAreaId&, CStateManager&);
void PutTo(CBitStreamWriter&);
};