From b1f07ba4fb39529faa433123a2e62a06936511bf Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 25 Jun 2015 18:57:32 +1000 Subject: [PATCH] Resolve merge issues and change the getSpells() interface. --- apps/opencs/model/world/data.cpp | 17 ++++++----------- apps/opencs/view/world/nestedtable.cpp | 16 ++++++++-------- apps/openmw/mwworld/mwstore.cpp | 5 +++-- apps/openmw/mwworld/mwstore.hpp | 2 +- apps/openmw/mwworld/store.hpp | 4 ---- components/autocalc/autocalcspell.cpp | 4 ++-- components/autocalc/store.hpp | 2 +- 7 files changed, 21 insertions(+), 29 deletions(-) diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index b789bd28f..47115f378 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -33,7 +33,6 @@ namespace const CSMWorld::IdCollection& mSkillTable; const CSMWorld::IdCollection& mMagicEffectTable; const CSMWorld::NestedIdCollection& mSpells; - std::vector mLocal; public: @@ -42,14 +41,8 @@ namespace const CSMWorld::IdCollection& magicEffects, const CSMWorld::NestedIdCollection& spells) : mGmstTable(gmst), mSkillTable(skills), mMagicEffectTable(magicEffects), mSpells(spells) - { - // prepare data in a format used by OpenMW store - for (int index = 0; index < mSpells.getSize(); ++index) - { - ESM::Spell *spell = const_cast(&mSpells.getRecord(index).get()); - mLocal.push_back(spell); - } - } + { } + ~CSStore() {} virtual int findGmstInt(const std::string& name) const @@ -74,9 +67,11 @@ namespace return &mMagicEffectTable.getRecord(ESM::MagicEffect::indexToId((short)id)).get(); } - virtual const std::vector& getSpells() const + virtual void getSpells(std::vector& spells) { - return mLocal; + // prepare data in a format used by OpenMW store + for (int index = 0; index < mSpells.getSize(); ++index) + spells.push_back(const_cast(&mSpells.getRecord(index).get())); } }; diff --git a/apps/opencs/view/world/nestedtable.cpp b/apps/opencs/view/world/nestedtable.cpp index 5d37947d2..e4447397d 100644 --- a/apps/opencs/view/world/nestedtable.cpp +++ b/apps/opencs/view/world/nestedtable.cpp @@ -16,6 +16,8 @@ CSVWorld::NestedTable::NestedTable(CSMDoc::Document& document, QWidget* parent, bool editable) : DragRecordTable(document, parent), + mAddNewRowAction(0), + mRemoveRowAction(0), mModel(model) { setSelectionBehavior (QAbstractItemView::SelectRows); @@ -50,8 +52,6 @@ CSVWorld::NestedTable::NestedTable(CSMDoc::Document& document, setItemDelegateForColumn(i, delegate); } - setModel(model); - mAddNewRowAction = new QAction (tr ("Add new row"), this); connect(mAddNewRowAction, SIGNAL(triggered()), @@ -90,15 +90,15 @@ void CSVWorld::NestedTable::contextMenuEvent (QContextMenuEvent *event) void CSVWorld::NestedTable::removeRowActionTriggered() { mDocument.getUndoStack().push(new CSMWorld::DeleteNestedCommand(*(mModel->model()), - mModel->getParentId(), - selectionModel()->selectedRows().begin()->row(), - mModel->getParentColumn())); + mModel->getParentId(), + selectionModel()->selectedRows().begin()->row(), + mModel->getParentColumn())); } void CSVWorld::NestedTable::addNewRowActionTriggered() { mDocument.getUndoStack().push(new CSMWorld::AddNestedCommand(*(mModel->model()), - mModel->getParentId(), - selectionModel()->selectedRows().size(), - mModel->getParentColumn())); + mModel->getParentId(), + selectionModel()->selectedRows().size(), + mModel->getParentColumn())); } diff --git a/apps/openmw/mwworld/mwstore.cpp b/apps/openmw/mwworld/mwstore.cpp index 8ebe91cd9..bdc61033e 100644 --- a/apps/openmw/mwworld/mwstore.cpp +++ b/apps/openmw/mwworld/mwstore.cpp @@ -29,8 +29,9 @@ namespace MWWorld return MWBase::Environment::get().getWorld()->getStore().get().find(id); } - const std::vector& MWStore::getSpells() const + void MWStore::getSpells(std::vector& spells) { - return MWBase::Environment::get().getWorld()->getStore().get().getShared(); + for (Store::iterator iter = mSpells.begin(); iter != mSpells.end(); ++iter) + spells.push_back(const_cast(&*iter)); } } diff --git a/apps/openmw/mwworld/mwstore.hpp b/apps/openmw/mwworld/mwstore.hpp index c43c58931..ba5060b0f 100644 --- a/apps/openmw/mwworld/mwstore.hpp +++ b/apps/openmw/mwworld/mwstore.hpp @@ -27,7 +27,7 @@ namespace MWWorld virtual const ESM::MagicEffect* findMagicEffect(int id) const; - virtual const std::vector& getSpells() const; + virtual void MWStore::getSpells(std::vector& spells); }; } diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index c86a92f7a..ab09782b1 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -234,10 +234,6 @@ namespace MWWorld return mShared.size(); } - const std::vector& getShared() const { - return mShared; - } - int getDynamicSize() const { return static_cast (mDynamic.size()); // truncated from unsigned __int64 if _MSC_VER && _WIN64 diff --git a/components/autocalc/autocalcspell.cpp b/components/autocalc/autocalcspell.cpp index 8f2883e1b..01c25a695 100644 --- a/components/autocalc/autocalcspell.cpp +++ b/components/autocalc/autocalcspell.cpp @@ -60,8 +60,8 @@ namespace AutoCalc } std::vector selectedSpells; - - const std::vector& spells = store->getSpells(); + std::vector spells; + store->getSpells(spells); // Note: the algorithm heavily depends on the traversal order of the spells. For vanilla-compatible results the // Store must preserve the record ordering as it was in the content files. diff --git a/components/autocalc/store.hpp b/components/autocalc/store.hpp index 65a29def7..67061eef9 100644 --- a/components/autocalc/store.hpp +++ b/components/autocalc/store.hpp @@ -36,7 +36,7 @@ namespace AutoCalc virtual const ESM::MagicEffect* findMagicEffect(int id) const = 0; - virtual const std::vector& getSpells() const = 0; + virtual void getSpells(std::vector& spells) = 0; }; } #endif // COMPONENTS_AUTOCALC_STORE_H