Rewrite NAME_T into FIXED_STRING.

pull/939/head
Roman Proskuryakov 9 years ago committed by Roman Proskuryakov
parent 964ea78367
commit d5dfa89060

@ -357,10 +357,10 @@ int load(Arguments& info)
EsmTool::RecordBase *record = EsmTool::RecordBase::create(n);
if (record == 0)
{
if (std::find(skipped.begin(), skipped.end(), n.val) == skipped.end())
if (std::find(skipped.begin(), skipped.end(), n.intval) == skipped.end())
{
std::cout << "Skipping " << n.toString() << " records." << std::endl;
skipped.push_back(n.val);
skipped.push_back(n.intval);
}
esm.skipRecord();
@ -392,7 +392,7 @@ int load(Arguments& info)
record->print();
}
if (record->getType().val == ESM::REC_CELL && loadCells && interested)
if (record->getType().intval == ESM::REC_CELL && loadCells && interested)
{
loadCell(record->cast<ESM::Cell>()->get(), esm, info);
}
@ -405,7 +405,7 @@ int load(Arguments& info)
{
delete record;
}
++info.data.mRecordStats[n.val];
++info.data.mRecordStats[n.intval];
}
} catch(std::exception &e) {
@ -448,14 +448,13 @@ int clone(Arguments& info)
std::cout << "Loaded " << recordCount << " records:" << std::endl << std::endl;
ESM::NAME name;
int i = 0;
typedef std::map<int, int> Stats;
Stats &stats = info.data.mRecordStats;
for (Stats::iterator it = stats.begin(); it != stats.end(); ++it)
{
name.val = it->first;
ESM::NAME name;
name.intval = it->first;
int amount = it->second;
std::cout << std::setw(digitCount) << amount << " " << name.toString() << " ";
@ -488,12 +487,12 @@ int clone(Arguments& info)
for (Records::iterator it = records.begin(); it != records.end() && i > 0; ++it)
{
EsmTool::RecordBase *record = *it;
name.val = record->getType().val;
const ESM::NAME& typeName = record->getType();
esm.startRecord(name.toString(), record->getFlags());
esm.startRecord(typeName.toString(), record->getFlags());
record->save(esm);
if (name.val == ESM::REC_CELL) {
if (typeName.intval == ESM::REC_CELL) {
ESM::Cell *ptr = &record->cast<ESM::Cell>()->get();
if (!info.data.mCellRefs[ptr].empty()) {
typedef std::deque<std::pair<ESM::CellRef, bool> > RefList;
@ -505,7 +504,7 @@ int clone(Arguments& info)
}
}
esm.endRecord(name.toString());
esm.endRecord(typeName.toString());
saved++;
int perc = (int)((saved / (float)recordCount)*100);

@ -179,7 +179,7 @@ RecordBase::create(ESM::NAME type)
{
RecordBase *record = 0;
switch (type.val) {
switch (type.intval) {
case ESM::REC_ACTI:
{
record = new EsmTool::Record<ESM::Activator>;

@ -322,14 +322,14 @@ namespace ESSImport
ESM::NAME n = esm.getRecName();
esm.getRecHeader();
std::map<unsigned int, boost::shared_ptr<Converter> >::iterator it = converters.find(n.val);
std::map<unsigned int, boost::shared_ptr<Converter> >::iterator it = converters.find(n.intval);
if (it != converters.end())
{
it->second->read(esm);
}
else
{
if (unknownRecords.insert(n.val).second)
if (unknownRecords.insert(n.intval).second)
{
std::ios::fmtflags f(std::cerr.flags());
std::cerr << "unknown record " << n.toString() << " (0x" << std::hex << esm.getFileOffset() << ")" << std::endl;

@ -942,7 +942,7 @@ bool CSMWorld::Data::continueLoading (CSMDoc::Messages& messages)
bool unhandledRecord = false;
switch (n.val)
switch (n.intval)
{
case ESM::REC_GLOB: mGlobals.load (*mReader, mBase); break;
case ESM::REC_GMST: mGmsts.load (*mReader, mBase); break;

@ -1187,7 +1187,7 @@ namespace CSMWorld
std::vector<ESM::ContItem>& list = container.mInventory.mList;
ESM::ContItem newRow = {0, {""}};
ESM::ContItem newRow = ESM::ContItem();
if (position >= (int)list.size())
list.push_back(newRow);

@ -385,7 +385,7 @@ void MWState::StateManager::loadGame (const Character *character, const std::str
ESM::NAME n = reader.getRecName();
reader.getRecHeader();
switch (n.val)
switch (n.intval)
{
case ESM::REC_SAVE:
{
@ -405,12 +405,12 @@ void MWState::StateManager::loadGame (const Character *character, const std::str
case ESM::REC_JOUR_LEGACY:
case ESM::REC_QUES:
MWBase::Environment::get().getJournal()->readRecord (reader, n.val);
MWBase::Environment::get().getJournal()->readRecord (reader, n.intval);
break;
case ESM::REC_DIAS:
MWBase::Environment::get().getDialogueManager()->readRecord (reader, n.val);
MWBase::Environment::get().getDialogueManager()->readRecord (reader, n.intval);
break;
case ESM::REC_ALCH:
@ -433,7 +433,7 @@ void MWState::StateManager::loadGame (const Character *character, const std::str
case ESM::REC_ENAB:
case ESM::REC_LEVC:
case ESM::REC_LEVI:
MWBase::Environment::get().getWorld()->readRecord(reader, n.val, contentFileMap);
MWBase::Environment::get().getWorld()->readRecord(reader, n.intval, contentFileMap);
break;
case ESM::REC_CAM_:
@ -442,7 +442,7 @@ void MWState::StateManager::loadGame (const Character *character, const std::str
case ESM::REC_GSCR:
MWBase::Environment::get().getScriptManager()->getGlobalScripts().readRecord (reader, n.val);
MWBase::Environment::get().getScriptManager()->getGlobalScripts().readRecord (reader, n.intval);
break;
case ESM::REC_GMAP:
@ -450,13 +450,13 @@ void MWState::StateManager::loadGame (const Character *character, const std::str
case ESM::REC_ASPL:
case ESM::REC_MARK:
MWBase::Environment::get().getWindowManager()->readRecord(reader, n.val);
MWBase::Environment::get().getWindowManager()->readRecord(reader, n.intval);
break;
case ESM::REC_DCOU:
case ESM::REC_STLN:
MWBase::Environment::get().getMechanicsManager()->readRecord(reader, n.val);
MWBase::Environment::get().getMechanicsManager()->readRecord(reader, n.intval);
break;
default:

@ -74,10 +74,10 @@ void ESMStore::load(ESM::ESMReader &esm, Loading::Listener* listener)
esm.getRecHeader();
// Look up the record type.
std::map<int, StoreBase *>::iterator it = mStores.find(n.val);
std::map<int, StoreBase *>::iterator it = mStores.find(n.intval);
if (it == mStores.end()) {
if (n.val == ESM::REC_INFO) {
if (n.intval == ESM::REC_INFO) {
if (dialogue)
{
dialogue->readInfo(esm, esm.getIndex() != 0);
@ -87,12 +87,12 @@ void ESMStore::load(ESM::ESMReader &esm, Loading::Listener* listener)
std::cerr << "error: info record without dialog" << std::endl;
esm.skipRecord();
}
} else if (n.val == ESM::REC_MGEF) {
} else if (n.intval == ESM::REC_MGEF) {
mMagicEffects.load (esm);
} else if (n.val == ESM::REC_SKIL) {
} else if (n.intval == ESM::REC_SKIL) {
mSkills.load (esm);
}
else if (n.val==ESM::REC_FILT || n.val == ESM::REC_DBGP)
else if (n.intval==ESM::REC_FILT || n.intval == ESM::REC_DBGP)
{
// ignore project file only records
esm.skipRecord();
@ -110,7 +110,7 @@ void ESMStore::load(ESM::ESMReader &esm, Loading::Listener* listener)
continue;
}
if (n.val==ESM::REC_DIAL) {
if (n.intval==ESM::REC_DIAL) {
dialogue = const_cast<ESM::Dialogue*>(mDialogs.find(id.mId));
} else {
dialogue = 0;

@ -62,7 +62,7 @@ void ESM::CellRef::loadData(ESMReader &esm, bool &isDeleted)
while (!isLoaded && esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::FourCC<'U','N','A','M'>::value:
esm.getHT(mReferenceBlocked);

@ -13,7 +13,7 @@ void ESM::DebugProfile::load (ESMReader& esm, bool &isDeleted)
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -15,43 +15,98 @@ enum Version
VER_13 = 0x3fa66666
};
/* A structure used for holding fixed-length strings. In the case of
LEN=4, it can be more efficient to match the string as a 32 bit
number, therefore the struct is implemented as a union with an int.
*/
template <int LEN>
union NAME_T
// CRTP for FIXED_STRING class, a structure used for holding fixed-length strings
template< template<size_t> class DERIVED, size_t SIZE>
class FIXED_STRING_BASE
{
char name[LEN];
uint32_t val;
/* The following methods must be implemented in derived classes:
* char const* ro_data() const; // return pointer to ro buffer
* char* rw_data(); // return pointer to rw buffer
*/
public:
enum { size = SIZE };
bool operator==(const char *str) const
{
for(int i=0; i<LEN; i++)
if(name[i] != str[i]) return false;
else if(name[i] == 0) return true;
return str[LEN] == 0;
}
bool operator!=(const char *str) const { return !((*this)==str); }
bool operator==(const std::string &str) const
{
return (*this) == str.c_str();
}
bool operator!=(const std::string &str) const { return !((*this)==str); }
template<size_t OTHER_SIZE>
bool operator==(char const (&str)[OTHER_SIZE]) const
{
size_t other_len = strnlen(str, OTHER_SIZE);
if (other_len != this->length())
return false;
return std::strncmp(self()->ro_data(), str, size) == 0;
}
bool operator==(const char* const str) const
{
char const* const data = self()->ro_data();
for(size_t i = 0; i < size; ++i)
{
if(data[i] != str[i]) return false;
else if(data[i] == '\0') return true;
}
return str[size] == '\0';
}
bool operator!=(const char* const str) const { return !( (*this) == str ); }
bool operator==(const std::string& str) const
{
return (*this) == str.c_str();
}
bool operator!=(const std::string& str) const { return !( (*this) == str ); }
size_t data_size() const { return size; }
size_t length() const { return strnlen(self()->ro_data(), size); }
std::string toString() const { return std::string(self()->ro_data(), this->length()); }
void assign(const std::string& value) { std::strncpy(self()->rw_data(), value.c_str(), size); }
void clear() { this->assign(""); }
private:
DERIVED<size> const* self() const
{
return static_cast<DERIVED<size> const*>(this);
}
// write the non-const version in terms of the const version
// Effective C++ 3rd ed., Item 3 (p. 24-25)
DERIVED<size>* self()
{
return const_cast<DERIVED<size>*>(static_cast<FIXED_STRING_BASE const*>(this)->self());
}
};
// Generic implementation
template <size_t SIZE>
struct FIXED_STRING : public FIXED_STRING_BASE<FIXED_STRING, SIZE>
{
char data[SIZE];
char const* ro_data() const { return data; }
char* rw_data() { return data; }
};
// In the case of SIZE=4, it can be more efficient to match the string
// as a 32 bit number, therefore the struct is implemented as a union with an int.
template <>
struct FIXED_STRING<4> : public FIXED_STRING_BASE<FIXED_STRING, 4>
{
union {
char data[4];
uint32_t intval;
};
bool operator==(uint32_t v) const { return v == val; }
bool operator!=(uint32_t v) const { return v != val; }
using FIXED_STRING_BASE::operator==;
using FIXED_STRING_BASE::operator!=;
std::string toString() const { return std::string(name, strnlen(name, LEN)); }
bool operator==(uint32_t v) const { return v == intval; }
bool operator!=(uint32_t v) const { return v != intval; }
void assign (const std::string& value) { std::strncpy (name, value.c_str(), LEN); }
char const* ro_data() const { return data; }
char* rw_data() { return data; }
};
typedef NAME_T<4> NAME;
typedef NAME_T<32> NAME32;
typedef NAME_T<64> NAME64;
typedef NAME_T<256> NAME256;
typedef FIXED_STRING<4> NAME;
typedef FIXED_STRING<32> NAME32;
typedef FIXED_STRING<64> NAME64;
typedef FIXED_STRING<256> NAME256;
/* This struct defines a file 'context' which can be saved and later
restored by an ESMReader instance. It will save the position within

@ -55,8 +55,8 @@ void ESMReader::close()
mCtx.leftRec = 0;
mCtx.leftSub = 0;
mCtx.subCached = false;
mCtx.recName.val = 0;
mCtx.subName.val = 0;
mCtx.recName.clear();
mCtx.subName.clear();
}
void ESMReader::openRaw(Files::IStreamPtr _esm, const std::string& name)
@ -204,16 +204,18 @@ void ESMReader::getSubName()
}
// reading the subrecord data anyway.
getExact(mCtx.subName.name, 4);
mCtx.leftRec -= 4;
const size_t subNameSize = mCtx.subName.data_size();
getExact(mCtx.subName.rw_data(), subNameSize);
mCtx.leftRec -= subNameSize;
}
bool ESMReader::isEmptyOrGetName()
{
if (mCtx.leftRec)
{
getExact(mCtx.subName.name, 4);
mCtx.leftRec -= 4;
const size_t subNameSize = mCtx.subName.data_size();
getExact(mCtx.subName.rw_data(), subNameSize);
mCtx.leftRec -= subNameSize;
return false;
}
return true;
@ -267,7 +269,7 @@ NAME ESMReader::getRecName()
if (!hasMoreRecs())
fail("No more records, getRecName() failed");
getName(mCtx.recName);
mCtx.leftFile -= 4;
mCtx.leftFile -= mCtx.recName.data_size();
// Make sure we don't carry over any old cached subrecord
// names. This can happen in some cases when we skip parts of a

@ -13,7 +13,7 @@ void ESM::Filter::load (ESMReader& esm, bool &isDeleted)
while (esm.hasMoreSubs())
{
esm.getSubName();
uint32_t name = esm.retSubName().val;
uint32_t name = esm.retSubName().intval;
switch (name)
{
case ESM::SREC_NAME:

@ -16,7 +16,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -19,7 +19,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -17,7 +17,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -49,7 +49,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -17,7 +17,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -17,7 +17,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -18,7 +18,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -69,7 +69,7 @@ namespace ESM
while (!isLoaded && esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mName = esm.getHString();
@ -114,7 +114,7 @@ namespace ESM
while (!isLoaded && esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::FourCC<'I','N','T','V'>::value:
int waterl;

@ -47,7 +47,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -19,7 +19,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -36,7 +36,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -30,7 +30,7 @@ namespace ESM {
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -28,7 +28,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::FourCC<'D','A','T','A'>::value:
{

@ -16,7 +16,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -18,7 +18,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -40,7 +40,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -35,7 +35,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::FourCC<'D','A','T','A'>::value:
esm.getHT(mData, 12);

@ -17,7 +17,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -94,7 +94,7 @@ namespace ESM
while (!isLoaded && esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::FourCC<'I','N','T','V'>::value:
esm.getSubHeaderIs(8);
@ -125,7 +125,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::FourCC<'V','N','M','L'>::value:
esm.skipHSub();

@ -15,7 +15,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -17,7 +17,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -17,7 +17,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -17,7 +17,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -211,7 +211,7 @@ void MagicEffect::load(ESMReader &esm, bool &isDeleted)
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::FourCC<'I','T','E','X'>::value:
mIcon = esm.getHString();

@ -17,7 +17,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -26,7 +26,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -46,7 +46,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mCell = esm.getHString();

@ -17,7 +17,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -29,7 +29,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -16,7 +16,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();
@ -61,10 +61,12 @@ namespace ESM
esm.getHT(mMapColor);
break;
case ESM::FourCC<'S','N','A','M'>::value:
{
SoundRef sr;
esm.getHT(sr, 33);
mSoundList.push_back(sr);
break;
}
case ESM::SREC_DELE:
esm.skipHSub();
isDeleted = true;

@ -17,7 +17,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -67,15 +67,17 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::FourCC<'S','C','H','D'>::value:
{
SCHD data;
esm.getHT(data, 52);
mData = data.mData;
mId = data.mName.toString();
hasHeader = true;
break;
}
case ESM::FourCC<'S','C','V','R'>::value:
// list of local variables
loadSCVR(esm);
@ -113,7 +115,7 @@ namespace ESM
memset(&data, 0, sizeof(data));
data.mData = mData;
memcpy(data.mName.name, mId.c_str(), mId.size());
data.mName.assign(mId);
esm.writeHNT("SCHD", data, 52);

@ -138,7 +138,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::FourCC<'I','N','D','X'>::value:
esm.getHT(mIndex);

@ -17,7 +17,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -17,7 +17,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -19,7 +19,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -17,7 +17,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -16,7 +16,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -9,8 +9,8 @@ void ESM::Header::blank()
{
mData.version = ESM::VER_13;
mData.type = 0;
mData.author.assign ("");
mData.desc.assign ("");
mData.author.clear();
mData.desc.clear();
mData.records = 0;
mFormat = CurrentFormat;
mMaster.clear();
@ -32,8 +32,8 @@ void ESM::Header::load (ESMReader &esm)
esm.getSubHeader();
esm.getT(mData.version);
esm.getT(mData.type);
mData.author.assign(esm.getString(sizeof(mData.author.name)));
mData.desc.assign(esm.getString(sizeof(mData.desc.name)));
mData.author.assign( esm.getString(mData.author.data_size()) );
mData.desc.assign( esm.getString(mData.desc.data_size()) );
esm.getT(mData.records);
}
@ -73,8 +73,8 @@ void ESM::Header::save (ESMWriter &esm)
esm.startSubRecord("HEDR");
esm.writeT(mData.version);
esm.writeT(mData.type);
esm.writeFixedSizeString(mData.author.toString(), 32);
esm.writeFixedSizeString(mData.desc.toString(), 256);
esm.writeFixedSizeString(mData.author.toString(), mData.author.data_size());
esm.writeFixedSizeString(mData.desc.toString(), mData.desc.data_size());
esm.writeT(mData.records);
esm.endRecord("HEDR");

@ -17,7 +17,7 @@ namespace ESM
while (esm.hasMoreSubs())
{
esm.getSubName();
switch (esm.retSubName().val)
switch (esm.retSubName().intval)
{
case ESM::SREC_NAME:
mId = esm.getHString();

@ -8,13 +8,13 @@ namespace ESM
void Transport::add(ESMReader &esm)
{
if (esm.retSubName().val == ESM::FourCC<'D','O','D','T'>::value)
if (esm.retSubName().intval == 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)
else if (esm.retSubName().intval == ESM::FourCC<'D','N','A','M'>::value)
{
mList.back().mCellName = esm.getHString();
}

Loading…
Cancel
Save