mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-19 19:53:53 +00:00
Write names with a small sanity check
This commit is contained in:
parent
7c1e417f9a
commit
b81ac363fc
5 changed files with 8 additions and 7 deletions
|
@ -17,6 +17,7 @@ void ESMWriter::writeHString(const std::string& data)
|
||||||
|
|
||||||
void ESMWriter::writeName(const std::string& name)
|
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);
|
write(name.c_str(), name.size()-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ void Land::load(ESMReader &esm)
|
||||||
|
|
||||||
void Land::save(ESMWriter &esm)
|
void Land::save(ESMWriter &esm)
|
||||||
{
|
{
|
||||||
esm.writeHString("INTV");
|
esm.writeName("INTV");
|
||||||
esm.writeT(X);
|
esm.writeT(X);
|
||||||
esm.writeT(Y);
|
esm.writeT(Y);
|
||||||
|
|
||||||
|
|
|
@ -38,9 +38,9 @@ void Tool::save(ESMWriter &esm)
|
||||||
|
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case Type_Repair: esm.writeHString("RIDT"); break;
|
case Type_Repair: esm.writeName("RIDT"); break;
|
||||||
case Type_Pick: esm.writeHString("LKDT"); break;
|
case Type_Pick: esm.writeName("LKDT"); break;
|
||||||
case Type_Probe: esm.writeHString("PBDT"); break;
|
case Type_Probe: esm.writeName("PBDT"); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
esm.writeT(data, 16);
|
esm.writeT(data, 16);
|
||||||
|
|
|
@ -74,7 +74,7 @@ void Pathgrid::save(ESMWriter &esm)
|
||||||
|
|
||||||
if (!points.empty())
|
if (!points.empty())
|
||||||
{
|
{
|
||||||
esm.writeHString("PGRP");
|
esm.writeName("PGRP");
|
||||||
for (PointList::iterator it = points.begin(); it != points.end(); ++it)
|
for (PointList::iterator it = points.begin(); it != points.end(); ++it)
|
||||||
{
|
{
|
||||||
esm.writeT(*it);
|
esm.writeT(*it);
|
||||||
|
@ -83,7 +83,7 @@ void Pathgrid::save(ESMWriter &esm)
|
||||||
|
|
||||||
if (!edges.empty())
|
if (!edges.empty())
|
||||||
{
|
{
|
||||||
esm.writeHString("PGRC");
|
esm.writeName("PGRC");
|
||||||
for (std::vector<Edge>::iterator it = edges.begin(); it != edges.end(); ++it)
|
for (std::vector<Edge>::iterator it = edges.begin(); it != edges.end(); ++it)
|
||||||
{
|
{
|
||||||
esm.writeT(it->v1);
|
esm.writeT(it->v1);
|
||||||
|
|
|
@ -44,7 +44,7 @@ void Script::save(ESMWriter &esm)
|
||||||
|
|
||||||
if (!varNames.empty())
|
if (!varNames.empty())
|
||||||
{
|
{
|
||||||
esm.writeHString("SCVR");
|
esm.writeName("SCVR");
|
||||||
for (std::vector<std::string>::iterator it = varNames.begin(); it != varNames.end(); ++it)
|
for (std::vector<std::string>::iterator it = varNames.begin(); it != varNames.end(); ++it)
|
||||||
{
|
{
|
||||||
esm.writeT(it->c_str(), it->size());
|
esm.writeT(it->c_str(), it->size());
|
||||||
|
|
Loading…
Reference in a new issue