Handle encoding conversions when saving TES3 header (Fixes #2727)

c++11
scrawl 10 years ago
parent 6d5823e8aa
commit 502cc852da

@ -174,6 +174,15 @@ namespace ESM
endRecord(name);
}
void ESMWriter::writeFixedSizeString(const std::string &data, int size)
{
std::string string;
if (!data.empty())
string = mEncoder ? mEncoder->getLegacyEnc(data) : data;
string.resize(size);
write(string.c_str(), string.size());
}
void ESMWriter::writeHString(const std::string& data)
{
if (data.size() == 0)

@ -120,6 +120,7 @@ public:
void startSubRecord(const std::string& name);
void endRecord(const std::string& name);
void endRecord(uint32_t name);
void writeFixedSizeString(const std::string& data, int size);
void writeHString(const std::string& data);
void writeHCString(const std::string& data);
void writeName(const std::string& data);

@ -71,7 +71,13 @@ void ESM::Header::save (ESMWriter &esm)
if (mFormat>0)
esm.writeHNT ("FORM", mFormat);
esm.writeHNT ("HEDR", mData, 300);
esm.startSubRecord("HEDR");
esm.writeT(mData.version);
esm.writeT(mData.type);
esm.writeFixedSizeString(mData.author.toString(), 32);
esm.writeFixedSizeString(mData.desc.toString(), 256);
esm.writeT(mData.records);
esm.endRecord("HEDR");
for (std::vector<Header::MasterData>::iterator iter = mMaster.begin();
iter != mMaster.end(); ++iter)

Loading…
Cancel
Save