mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 15:15:31 +00:00
Adjust edge indexes when adding/removing points. Fix some travis warnings.
This commit is contained in:
parent
23db79ebab
commit
be9f94b766
3 changed files with 28 additions and 5 deletions
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
namespace CSMWorld
|
namespace CSMWorld
|
||||||
{
|
{
|
||||||
class NestedTableWrapperBase;
|
struct NestedTableWrapperBase;
|
||||||
|
|
||||||
template<typename ESXRecordT>
|
template<typename ESXRecordT>
|
||||||
class PathgridPointListAdapter : public NestedIdAdapter<ESXRecordT>
|
class PathgridPointListAdapter : public NestedIdAdapter<ESXRecordT>
|
||||||
|
@ -32,7 +32,16 @@ namespace CSMWorld
|
||||||
point.mConnectionNum = 0;
|
point.mConnectionNum = 0;
|
||||||
point.mUnknown = 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<ESM::Pathgrid::Edge>::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);
|
points.insert(points.begin()+position, point);
|
||||||
pathgrid.mData.mS2 += 1; // increment the number of points
|
pathgrid.mData.mS2 += 1; // increment the number of points
|
||||||
|
|
||||||
|
@ -48,7 +57,21 @@ namespace CSMWorld
|
||||||
if (rowToRemove < 0 || rowToRemove >= static_cast<int> (points.size()))
|
if (rowToRemove < 0 || rowToRemove >= static_cast<int> (points.size()))
|
||||||
throw std::runtime_error ("index out of range");
|
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<ESM::Pathgrid::Edge>::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);
|
points.erase(points.begin()+rowToRemove);
|
||||||
pathgrid.mData.mS2 -= 1; // decrement the number of points
|
pathgrid.mData.mS2 -= 1; // decrement the number of points
|
||||||
|
|
||||||
|
|
|
@ -393,7 +393,7 @@ namespace CSMWorld
|
||||||
{
|
{
|
||||||
std::vector<ESM::ContItem>& list = CastableHelper<ESXRecordT>::getRecord(data, index).get().mInventory.mList;
|
std::vector<ESM::ContItem>& list = CastableHelper<ESXRecordT>::getRecord(data, index).get().mInventory.mList;
|
||||||
|
|
||||||
ESM::ContItem newRow = {0, ""};
|
ESM::ContItem newRow = {0, {""}};
|
||||||
if (position >= (int)list.size())
|
if (position >= (int)list.size())
|
||||||
{
|
{
|
||||||
list.push_back(newRow);
|
list.push_back(newRow);
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
namespace CSMWorld
|
namespace CSMWorld
|
||||||
{
|
{
|
||||||
class CollectionBase;
|
class CollectionBase;
|
||||||
class RecordBase;
|
struct RecordBase;
|
||||||
class IdTree;
|
class IdTree;
|
||||||
|
|
||||||
class NestedTableProxyModel : public QAbstractProxyModel
|
class NestedTableProxyModel : public QAbstractProxyModel
|
||||||
|
|
Loading…
Reference in a new issue