openmw-tes3coop/components/esm/loadlocks.cpp

53 lines
1.1 KiB
C++
Raw Normal View History

#include "loadlocks.hpp"
namespace ESM
{
void Tool::load(ESMReader &esm)
{
model = esm.getHNString("MODL");
name = esm.getHNString("FNAM");
esm.getSubName();
NAME n = esm.retSubName();
// The data name varies, RIDT for repair items, LKDT for lock
// picks, PBDT for probes
esm.getHT(data, 16);
if (n == "RIDT")
{
type = Type_Repair;
// Swap t.data.quality and t.data.uses for repair items (sigh)
float tmp = *((float*) &data.uses);
data.uses = *((int*) &data.quality);
data.quality = tmp;
}
else if (n == "LKDT")
type = Type_Pick;
else if (n == "PBDT")
type = Type_Probe;
script = esm.getHNOString("SCRI");
icon = esm.getHNOString("ITEX");
}
void Tool::save(ESMWriter &esm)
{
esm.writeHNString("MODL", model);
esm.writeHNString("FNAM", name);
switch(type)
{
2012-04-06 19:28:58 +00:00
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);
2012-04-06 19:14:52 +00:00
esm.writeHNOString("SCRI", script);
esm.writeHNOString("ITEX", icon);
}
}