From 5ff66ad40b5f439e9fb676c1b5ab90a473753d59 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 1 Mar 2015 13:09:23 +1100 Subject: [PATCH] Fix Bug #2402. SKIL records should not have NAME subrecord. --- apps/opencs/model/doc/savingstages.hpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/doc/savingstages.hpp b/apps/opencs/model/doc/savingstages.hpp index 87c9ba7eb..6607e9968 100644 --- a/apps/opencs/model/doc/savingstages.hpp +++ b/apps/opencs/model/doc/savingstages.hpp @@ -103,8 +103,20 @@ namespace CSMDoc if (state==CSMWorld::RecordBase::State_Modified || state==CSMWorld::RecordBase::State_ModifiedOnly) { - mState.getWriter().startRecord (mCollection.getRecord (stage).mModified.sRecordId); - mState.getWriter().writeHNCString ("NAME", mCollection.getId (stage)); + // FIXME: A quick Workaround to support SKIL records which should not write NAME. + // If there are more idcollection records that don't use NAME then a more + // generic solution may be required. The conversion code was simply + // copied from esmwriter. There's room for improving speed a little bit + // here if it turns out to be an issue. + uint32_t name = mCollection.getRecord (stage).mModified.sRecordId; + mState.getWriter().startRecord (name); + std::string type; + for (int i=0; i<4; ++i) + /// \todo make endianess agnostic + type += reinterpret_cast (&name)[i]; + + if(type != "SKIL") + mState.getWriter().writeHNCString ("NAME", mCollection.getId (stage)); mCollection.getRecord (stage).mModified.save (mState.getWriter()); mState.getWriter().endRecord (mCollection.getRecord (stage).mModified.sRecordId); }