diff --git a/apps/opencs/model/world/idadapterimp.hpp b/apps/opencs/model/world/idadapterimp.hpp index 025c2e137..aed847909 100644 --- a/apps/opencs/model/world/idadapterimp.hpp +++ b/apps/opencs/model/world/idadapterimp.hpp @@ -9,7 +9,7 @@ namespace CSMWorld { - class NestedTableWrapperBase; + struct NestedTableWrapperBase; template class PathgridPointListAdapter : public NestedIdAdapter @@ -32,7 +32,16 @@ namespace CSMWorld point.mConnectionNum = 0; point.mUnknown = 0; - // FIXME: inserting a point should trigger re-indexing of the edges + // inserting a point should trigger re-indexing of the edges + std::vector::iterator iter = pathgrid.mEdges.begin(); + for (;iter != pathgrid.mEdges.end(); ++iter) + { + if ((*iter).mV0 > position) + (*iter).mV0++; + if ((*iter).mV1 > position) + (*iter).mV1++; + } + points.insert(points.begin()+position, point); pathgrid.mData.mS2 += 1; // increment the number of points @@ -48,7 +57,21 @@ namespace CSMWorld if (rowToRemove < 0 || rowToRemove >= static_cast (points.size())) throw std::runtime_error ("index out of range"); - // FIXME: deleting a point should trigger re-indexing of the edges + // deleting a point should trigger re-indexing of the edges + // dangling edges are not allowed and hence removed + std::vector::iterator iter = pathgrid.mEdges.begin(); + for (;iter != pathgrid.mEdges.end(); ++iter) + { + if (((*iter).mV0 == rowToRemove) || ((*iter).mV1 == rowToRemove)) + pathgrid.mEdges.erase(iter); + + if ((*iter).mV0 > rowToRemove) + (*iter).mV0--; + + if ((*iter).mV1 > rowToRemove) + (*iter).mV1--; + } + points.erase(points.begin()+rowToRemove); pathgrid.mData.mS2 -= 1; // decrement the number of points diff --git a/apps/opencs/model/world/nestedadapters.hpp b/apps/opencs/model/world/nestedadapters.hpp index a2cbea1a6..015765380 100644 --- a/apps/opencs/model/world/nestedadapters.hpp +++ b/apps/opencs/model/world/nestedadapters.hpp @@ -393,7 +393,7 @@ namespace CSMWorld { std::vector& list = CastableHelper::getRecord(data, index).get().mInventory.mList; - ESM::ContItem newRow = {0, ""}; + ESM::ContItem newRow = {0, {""}}; if (position >= (int)list.size()) { list.push_back(newRow); diff --git a/apps/opencs/model/world/nestedtableproxymodel.hpp b/apps/opencs/model/world/nestedtableproxymodel.hpp index 177a25d28..2ab04a584 100644 --- a/apps/opencs/model/world/nestedtableproxymodel.hpp +++ b/apps/opencs/model/world/nestedtableproxymodel.hpp @@ -16,7 +16,7 @@ namespace CSMWorld { class CollectionBase; - class RecordBase; + struct RecordBase; class IdTree; class NestedTableProxyModel : public QAbstractProxyModel