Add travel service support for creatures (Fixes #2432)
parent
457c135097
commit
e30f240ba2
@ -0,0 +1,33 @@
|
||||
#include "transport.hpp"
|
||||
|
||||
#include <components/esm/esmreader.hpp>
|
||||
#include <components/esm/esmwriter.hpp>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
|
||||
void Transport::add(ESMReader &esm)
|
||||
{
|
||||
if (esm.retSubName().val == ESM::FourCC<'D','O','D','T'>::value)
|
||||
{
|
||||
Dest dodt;
|
||||
esm.getHExact(&dodt.mPos, 24);
|
||||
mList.push_back(dodt);
|
||||
}
|
||||
else if (esm.retSubName().val == ESM::FourCC<'D','N','A','M'>::value)
|
||||
{
|
||||
mList.back().mCellName = esm.getHString();
|
||||
}
|
||||
}
|
||||
|
||||
void Transport::save(ESMWriter &esm) const
|
||||
{
|
||||
typedef std::vector<Dest>::const_iterator DestIter;
|
||||
for (DestIter it = mList.begin(); it != mList.end(); ++it)
|
||||
{
|
||||
esm.writeHNT("DODT", it->mPos, sizeof(it->mPos));
|
||||
esm.writeHNOCString("DNAM", it->mCellName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
#ifndef OPENMW_COMPONENTS_ESM_TRANSPORT_H
|
||||
#define OPENMW_COMPONENTS_ESM_TRANSPORT_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "defs.hpp"
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
|
||||
class ESMReader;
|
||||
class ESMWriter;
|
||||
|
||||
/// List of travel service destination. Shared by CREA and NPC_ records.
|
||||
struct Transport
|
||||
{
|
||||
|
||||
struct Dest
|
||||
{
|
||||
Position mPos;
|
||||
std::string mCellName;
|
||||
};
|
||||
|
||||
std::vector<Dest> mList;
|
||||
|
||||
/// Load one destination, assumes the subrecord name was already read
|
||||
void add(ESMReader &esm);
|
||||
|
||||
void save(ESMWriter &esm) const;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue