mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-15 20:19:56 +00:00
54 lines
1.2 KiB
C++
54 lines
1.2 KiB
C++
#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)
|
|
{
|
|
case Type_Repair: esm.writeHString("RIDT"); break;
|
|
case Type_Pick: esm.writeHString("LKDT"); break;
|
|
case Type_Probe: esm.writeHString("PBDT"); break;
|
|
}
|
|
|
|
esm.writeT(data, 16);
|
|
if (!script.empty())
|
|
esm.writeHNString("SCRI", script);
|
|
if (!icon.empty())
|
|
esm.writeHNString("ITEX", icon);
|
|
}
|
|
|
|
|
|
}
|