moved header record struct to separate file
parent
731ac6a160
commit
16570ce87b
@ -0,0 +1,40 @@
|
||||
|
||||
#include "loadtes3.hpp"
|
||||
|
||||
#include "esmcommon.hpp"
|
||||
#include "esmreader.hpp"
|
||||
#include "esmwriter.hpp"
|
||||
|
||||
void ESM::Header::blank()
|
||||
{
|
||||
mData.version = ESM::VER_13;
|
||||
mData.type = 0;
|
||||
mData.author.assign ("");
|
||||
mData.desc.assign ("");
|
||||
mData.records = 0;
|
||||
}
|
||||
|
||||
void ESM::Header::load (ESMReader &esm)
|
||||
{
|
||||
esm.getHNT (mData, "HEDR", 300);
|
||||
|
||||
while (esm.isNextSub ("MAST"))
|
||||
{
|
||||
MasterData m;
|
||||
m.name = esm.getHString();
|
||||
m.size = esm.getHNLong ("DATA");
|
||||
mMaster.push_back (m);
|
||||
}
|
||||
}
|
||||
|
||||
void ESM::Header::save (ESMWriter &esm)
|
||||
{
|
||||
esm.writeHNT ("HEDR", mData, 300);
|
||||
|
||||
for (std::vector<Header::MasterData>::iterator iter = mMaster.begin();
|
||||
iter != mMaster.end(); ++iter)
|
||||
{
|
||||
esm.writeHNCString ("MAST", iter->name);
|
||||
esm.writeHNT ("DATA", iter->size);
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
#ifndef COMPONENT_ESM_TES3_H
|
||||
#define COMPONENT_ESM_TES3_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "esmcommon.hpp"
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
class ESMReader;
|
||||
class ESMWriter;
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
/// \brief File header record
|
||||
struct Header
|
||||
{
|
||||
struct Data
|
||||
{
|
||||
/* File format version. This is actually a float, the supported
|
||||
versions are 1.2 and 1.3. These correspond to:
|
||||
1.2 = 0x3f99999a and 1.3 = 0x3fa66666
|
||||
*/
|
||||
int version;
|
||||
int type; // 0=esp, 1=esm, 32=ess (unused)
|
||||
NAME32 author; // Author's name
|
||||
NAME256 desc; // File description
|
||||
int records; // Number of records? Not used.
|
||||
};
|
||||
|
||||
// Defines another files (esm or esp) that this file depends upon.
|
||||
struct MasterData
|
||||
{
|
||||
std::string name;
|
||||
uint64_t size;
|
||||
int index; // Position of the parent file in the global list of loaded files
|
||||
};
|
||||
|
||||
Data mData;
|
||||
std::vector<MasterData> mMaster;
|
||||
|
||||
void blank();
|
||||
|
||||
void load (ESMReader &esm);
|
||||
void save (ESMWriter &esm);
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue