mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 22:15:32 +00:00
Handle encoding conversions when saving TES3 header (Fixes #2727)
This commit is contained in:
parent
6d5823e8aa
commit
502cc852da
3 changed files with 17 additions and 1 deletions
|
@ -174,6 +174,15 @@ namespace ESM
|
||||||
endRecord(name);
|
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)
|
void ESMWriter::writeHString(const std::string& data)
|
||||||
{
|
{
|
||||||
if (data.size() == 0)
|
if (data.size() == 0)
|
||||||
|
|
|
@ -120,6 +120,7 @@ public:
|
||||||
void startSubRecord(const std::string& name);
|
void startSubRecord(const std::string& name);
|
||||||
void endRecord(const std::string& name);
|
void endRecord(const std::string& name);
|
||||||
void endRecord(uint32_t name);
|
void endRecord(uint32_t name);
|
||||||
|
void writeFixedSizeString(const std::string& data, int size);
|
||||||
void writeHString(const std::string& data);
|
void writeHString(const std::string& data);
|
||||||
void writeHCString(const std::string& data);
|
void writeHCString(const std::string& data);
|
||||||
void writeName(const std::string& data);
|
void writeName(const std::string& data);
|
||||||
|
|
|
@ -71,7 +71,13 @@ void ESM::Header::save (ESMWriter &esm)
|
||||||
if (mFormat>0)
|
if (mFormat>0)
|
||||||
esm.writeHNT ("FORM", mFormat);
|
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();
|
for (std::vector<Header::MasterData>::iterator iter = mMaster.begin();
|
||||||
iter != mMaster.end(); ++iter)
|
iter != mMaster.end(); ++iter)
|
||||||
|
|
Loading…
Reference in a new issue