forked from mirror/openmw-tes3mp
32f051d61d
The 'fixing' for so-called dirty GMSTs does not work properly in its current state anyway, so it should be removed. Fixing the 'GMST fixing' might not be possible, because whether or not a GMST is 'dirty' depends on the language version of MW. Therefore different 'fixing' algorithms would be required for the different MW localisations, and I do not see a good reason why GMST values should be hard-coded in the GMST load procedure. In my opinion, it only clutters the code. Last but not least, I believe that it is not the task of the engine to clean ESM files from dirty entries. That is a job for the modders, who should only release clean ESM/ESP files in the first place. The engine should not need to worry about whether a file is 'dirty' or not. That is why I believe a feature for cleaning ESM/ESP files shall not be part of the engine.
85 lines
1.6 KiB
C++
85 lines
1.6 KiB
C++
#include "loadgmst.hpp"
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <boost/algorithm/string.hpp>
|
|
|
|
#include "esmreader.hpp"
|
|
#include "esmwriter.hpp"
|
|
|
|
namespace ESM
|
|
{
|
|
|
|
void GameSetting::load(ESMReader &esm)
|
|
{
|
|
assert(mId != "");
|
|
|
|
// We are apparently allowed to be empty
|
|
if (!esm.hasMoreSubs())
|
|
{
|
|
mType = VT_None;
|
|
return;
|
|
}
|
|
|
|
// Load some data
|
|
esm.getSubName();
|
|
NAME n = esm.retSubName();
|
|
if (n == "STRV")
|
|
{
|
|
mStr = esm.getHString();
|
|
mType = VT_String;
|
|
}
|
|
else if (n == "INTV")
|
|
{
|
|
esm.getHT(mI);
|
|
mType = VT_Int;
|
|
}
|
|
else if (n == "FLTV")
|
|
{
|
|
esm.getHT(mF);
|
|
mType = VT_Float;
|
|
}
|
|
else
|
|
esm.fail("Unwanted subrecord type");
|
|
}
|
|
|
|
void GameSetting::save(ESMWriter &esm)
|
|
{
|
|
switch(mType)
|
|
{
|
|
case VT_String: esm.writeHNString("STRV", mStr); break;
|
|
case VT_Int: esm.writeHNT("INTV", mI); break;
|
|
case VT_Float: esm.writeHNT("FLTV", mF); break;
|
|
default: break;
|
|
}
|
|
}
|
|
|
|
int GameSetting::getInt() const
|
|
{
|
|
switch (mType)
|
|
{
|
|
case VT_Float: return static_cast<int> (mF);
|
|
case VT_Int: return mI;
|
|
default: throw std::runtime_error ("GMST " + mId + " is not of a numeric type");
|
|
}
|
|
}
|
|
|
|
float GameSetting::getFloat() const
|
|
{
|
|
switch (mType)
|
|
{
|
|
case VT_Float: return mF;
|
|
case VT_Int: return mI;
|
|
default: throw std::runtime_error ("GMST " + mId + " is not of a numeric type");
|
|
}
|
|
}
|
|
|
|
std::string GameSetting::getString() const
|
|
{
|
|
if (mType==VT_String)
|
|
return mStr;
|
|
|
|
throw std::runtime_error ("GMST " + mId + " is not a string");
|
|
}
|
|
|
|
}
|