Write names with a small sanity check

actorid
Alexander "Ace" Olofsson 13 years ago
parent 7c1e417f9a
commit b81ac363fc

@ -17,6 +17,7 @@ void ESMWriter::writeHString(const std::string& data)
void ESMWriter::writeName(const std::string& name)
{
assert((name.size() == 4 && name.c_str()[3] != '\0') || (name.size() == 5 && name.c_str()[4] == '\0'));
write(name.c_str(), name.size()-1);
}

@ -84,7 +84,7 @@ void Land::load(ESMReader &esm)
void Land::save(ESMWriter &esm)
{
esm.writeHString("INTV");
esm.writeName("INTV");
esm.writeT(X);
esm.writeT(Y);

@ -38,9 +38,9 @@ void Tool::save(ESMWriter &esm)
switch(type)
{
case Type_Repair: esm.writeHString("RIDT"); break;
case Type_Pick: esm.writeHString("LKDT"); break;
case Type_Probe: esm.writeHString("PBDT"); break;
case Type_Repair: esm.writeName("RIDT"); break;
case Type_Pick: esm.writeName("LKDT"); break;
case Type_Probe: esm.writeName("PBDT"); break;
}
esm.writeT(data, 16);

@ -74,7 +74,7 @@ void Pathgrid::save(ESMWriter &esm)
if (!points.empty())
{
esm.writeHString("PGRP");
esm.writeName("PGRP");
for (PointList::iterator it = points.begin(); it != points.end(); ++it)
{
esm.writeT(*it);
@ -83,7 +83,7 @@ void Pathgrid::save(ESMWriter &esm)
if (!edges.empty())
{
esm.writeHString("PGRC");
esm.writeName("PGRC");
for (std::vector<Edge>::iterator it = edges.begin(); it != edges.end(); ++it)
{
esm.writeT(it->v1);

@ -44,7 +44,7 @@ void Script::save(ESMWriter &esm)
if (!varNames.empty())
{
esm.writeHString("SCVR");
esm.writeName("SCVR");
for (std::vector<std::string>::iterator it = varNames.begin(); it != varNames.end(); ++it)
{
esm.writeT(it->c_str(), it->size());

Loading…
Cancel
Save