diff --git a/apps/opencs/model/world/nestedadaptors.hpp b/apps/opencs/model/world/nestedadaptors.hpp index a961d19e4..9e747164a 100644 --- a/apps/opencs/model/world/nestedadaptors.hpp +++ b/apps/opencs/model/world/nestedadaptors.hpp @@ -90,6 +90,20 @@ namespace CSMWorld } } + void addNestedRow (const RefIdColumn *column, RefIdData& data, int index, int position) const + { + std::vector& list = getRecord(data, index).get().mInventory.mList; + + ESM::ContItem newRow = {0, ""}; + if (position >= (int)list.size()) + { + list.push_back(newRow); + return; + } + + list.insert(list.begin()+position, newRow); + } + private: const Record& getRecord(const RefIdData& data, int index) const diff --git a/apps/opencs/model/world/refidadapterimp.cpp b/apps/opencs/model/world/refidadapterimp.cpp index 2a8fec01d..5681b8bae 100644 --- a/apps/opencs/model/world/refidadapterimp.cpp +++ b/apps/opencs/model/world/refidadapterimp.cpp @@ -232,21 +232,12 @@ void CSMWorld::ContainerRefIdAdapter::removeNestedRow (const RefIdColumn *column void CSMWorld::ContainerRefIdAdapter::addNestedRow (const RefIdColumn *column, RefIdData& data, int index, int position) const { - assert(column==mContent); - - std::vector& list = static_cast&> ( - data.getRecord (RefIdData::LocalIndex (index, UniversalId::Type_Container))).get().mInventory.mList; - - ESM::ContItem newRow = {0, ""}; - if (position >= (int)list.size()) + if(column!=mContent) { - list.push_back(newRow); - return; + throw std::logic_error("This column does not hold multiple values."); } - list.insert(list.begin()+position, newRow); - - return; + mHelper.addNestedRow(column, data, index, position); } void CSMWorld::ContainerRefIdAdapter::setData (const RefIdColumn *column, RefIdData& data, int index,