From f2972b1ca0c600b04da00c747b36cb8e012009c5 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 28 Jan 2012 11:45:55 +0100 Subject: [PATCH 01/11] turned ContainerStore from a template into a simple struct --- apps/openmw/mwclass/apparatus.cpp | 2 +- apps/openmw/mwclass/apparatus.hpp | 2 +- apps/openmw/mwclass/armor.cpp | 2 +- apps/openmw/mwclass/armor.hpp | 2 +- apps/openmw/mwclass/book.cpp | 2 +- apps/openmw/mwclass/book.hpp | 2 +- apps/openmw/mwclass/clothing.cpp | 2 +- apps/openmw/mwclass/clothing.hpp | 2 +- apps/openmw/mwclass/container.cpp | 4 ++-- apps/openmw/mwclass/container.hpp | 3 +-- apps/openmw/mwclass/creature.cpp | 4 ++-- apps/openmw/mwclass/creature.hpp | 2 +- apps/openmw/mwclass/ingredient.cpp | 2 +- apps/openmw/mwclass/ingredient.hpp | 2 +- apps/openmw/mwclass/light.cpp | 2 +- apps/openmw/mwclass/light.hpp | 2 +- apps/openmw/mwclass/lockpick.cpp | 2 +- apps/openmw/mwclass/lockpick.hpp | 2 +- apps/openmw/mwclass/misc.cpp | 2 +- apps/openmw/mwclass/misc.hpp | 2 +- apps/openmw/mwclass/npc.cpp | 4 ++-- apps/openmw/mwclass/npc.hpp | 3 +-- apps/openmw/mwclass/potion.cpp | 2 +- apps/openmw/mwclass/potion.hpp | 2 +- apps/openmw/mwclass/probe.cpp | 4 ++-- apps/openmw/mwclass/probe.hpp | 2 +- apps/openmw/mwclass/repair.cpp | 2 +- apps/openmw/mwclass/repair.hpp | 2 +- apps/openmw/mwclass/weapon.cpp | 2 +- apps/openmw/mwclass/weapon.hpp | 2 +- apps/openmw/mwworld/class.cpp | 4 ++-- apps/openmw/mwworld/class.hpp | 6 ++---- apps/openmw/mwworld/containerstore.hpp | 27 +++++++++++++------------- apps/openmw/mwworld/containerutil.cpp | 2 +- apps/openmw/mwworld/containerutil.hpp | 3 +-- 35 files changed, 54 insertions(+), 58 deletions(-) diff --git a/apps/openmw/mwclass/apparatus.cpp b/apps/openmw/mwclass/apparatus.cpp index cc30c6955..77819a97c 100644 --- a/apps/openmw/mwclass/apparatus.cpp +++ b/apps/openmw/mwclass/apparatus.cpp @@ -60,7 +60,7 @@ namespace MWClass } void Apparatus::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const + MWWorld::ContainerStore& containerStore) const { insertIntoContainerStore (ptr, containerStore.appas); } diff --git a/apps/openmw/mwclass/apparatus.hpp b/apps/openmw/mwclass/apparatus.hpp index 9a5a9b955..95bcbd38b 100644 --- a/apps/openmw/mwclass/apparatus.hpp +++ b/apps/openmw/mwclass/apparatus.hpp @@ -23,7 +23,7 @@ namespace MWClass ///< Generate action for activation virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; + MWWorld::ContainerStore& containerStore) const; ///< Insert into a containe virtual std::string getScript (const MWWorld::Ptr& ptr) const; diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index 9a0936027..f62167d4f 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -72,7 +72,7 @@ namespace MWClass } void Armor::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const + MWWorld::ContainerStore& containerStore) const { insertIntoContainerStore (ptr, containerStore.armors); } diff --git a/apps/openmw/mwclass/armor.hpp b/apps/openmw/mwclass/armor.hpp index 123713a38..0950e0744 100644 --- a/apps/openmw/mwclass/armor.hpp +++ b/apps/openmw/mwclass/armor.hpp @@ -29,7 +29,7 @@ namespace MWClass ///< Return item max health or throw an exception, if class does not have item health virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; + MWWorld::ContainerStore& containerStore) const; ///< Insert into a containe virtual std::string getScript (const MWWorld::Ptr& ptr) const; diff --git a/apps/openmw/mwclass/book.cpp b/apps/openmw/mwclass/book.cpp index 8c5be4793..2f3d1dcfa 100644 --- a/apps/openmw/mwclass/book.cpp +++ b/apps/openmw/mwclass/book.cpp @@ -62,7 +62,7 @@ namespace MWClass } void Book::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const + MWWorld::ContainerStore& containerStore) const { insertIntoContainerStore (ptr, containerStore.books); } diff --git a/apps/openmw/mwclass/book.hpp b/apps/openmw/mwclass/book.hpp index 6e38ea0d3..41cf5ba4a 100644 --- a/apps/openmw/mwclass/book.hpp +++ b/apps/openmw/mwclass/book.hpp @@ -23,7 +23,7 @@ namespace MWClass ///< Generate action for activation virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; + MWWorld::ContainerStore& containerStore) const; ///< Insert into a containe virtual std::string getScript (const MWWorld::Ptr& ptr) const; diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp index 3826c6c40..c9d7f0b06 100644 --- a/apps/openmw/mwclass/clothing.cpp +++ b/apps/openmw/mwclass/clothing.cpp @@ -60,7 +60,7 @@ namespace MWClass } void Clothing::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const + MWWorld::ContainerStore& containerStore) const { insertIntoContainerStore (ptr, containerStore.clothes); } diff --git a/apps/openmw/mwclass/clothing.hpp b/apps/openmw/mwclass/clothing.hpp index 353f7f606..25ba3456c 100644 --- a/apps/openmw/mwclass/clothing.hpp +++ b/apps/openmw/mwclass/clothing.hpp @@ -23,7 +23,7 @@ namespace MWClass ///< Generate action for activation virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; + MWWorld::ContainerStore& containerStore) const; ///< Insert into a containe virtual std::string getScript (const MWWorld::Ptr& ptr) const; diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 13a6241d4..1ad9e845e 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -15,7 +15,7 @@ namespace { struct CustomData : public MWWorld::CustomData { - MWWorld::ContainerStore mContainerStore; + MWWorld::ContainerStore mContainerStore; virtual MWWorld::CustomData *clone() const; }; @@ -79,7 +79,7 @@ namespace MWClass return ref->base->name; } - MWWorld::ContainerStore& Container::getContainerStore (const MWWorld::Ptr& ptr) + MWWorld::ContainerStore& Container::getContainerStore (const MWWorld::Ptr& ptr) const { ensureCustomData (ptr); diff --git a/apps/openmw/mwclass/container.hpp b/apps/openmw/mwclass/container.hpp index 78552ffe9..66a47a956 100644 --- a/apps/openmw/mwclass/container.hpp +++ b/apps/openmw/mwclass/container.hpp @@ -20,8 +20,7 @@ namespace MWClass ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. - virtual MWWorld::ContainerStore& getContainerStore ( - const MWWorld::Ptr& ptr) const; + virtual MWWorld::ContainerStore& getContainerStore (const MWWorld::Ptr& ptr) const; ///< Return container store virtual std::string getScript (const MWWorld::Ptr& ptr) const; diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 12a56e0ee..7270fd22b 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -17,7 +17,7 @@ namespace struct CustomData : public MWWorld::CustomData { MWMechanics::CreatureStats mCreatureStats; - MWWorld::ContainerStore mContainerStore; + MWWorld::ContainerStore mContainerStore; virtual MWWorld::CustomData *clone() const; }; @@ -118,7 +118,7 @@ namespace MWClass return boost::shared_ptr (new MWWorld::ActionTalk (ptr)); } - MWWorld::ContainerStore& Creature::getContainerStore (const MWWorld::Ptr& ptr) + MWWorld::ContainerStore& Creature::getContainerStore (const MWWorld::Ptr& ptr) const { ensureCustomData (ptr); diff --git a/apps/openmw/mwclass/creature.hpp b/apps/openmw/mwclass/creature.hpp index 9afeffea8..8eb45e838 100644 --- a/apps/openmw/mwclass/creature.hpp +++ b/apps/openmw/mwclass/creature.hpp @@ -39,7 +39,7 @@ namespace MWClass const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; ///< Generate action for activation - virtual MWWorld::ContainerStore& getContainerStore ( + virtual MWWorld::ContainerStore& getContainerStore ( const MWWorld::Ptr& ptr) const; ///< Return container store diff --git a/apps/openmw/mwclass/ingredient.cpp b/apps/openmw/mwclass/ingredient.cpp index ac1076cc1..3a7594496 100644 --- a/apps/openmw/mwclass/ingredient.cpp +++ b/apps/openmw/mwclass/ingredient.cpp @@ -58,7 +58,7 @@ namespace MWClass } void Ingredient::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const + MWWorld::ContainerStore& containerStore) const { insertIntoContainerStore (ptr, containerStore.ingreds); } diff --git a/apps/openmw/mwclass/ingredient.hpp b/apps/openmw/mwclass/ingredient.hpp index 6c7409665..60cb21fac 100644 --- a/apps/openmw/mwclass/ingredient.hpp +++ b/apps/openmw/mwclass/ingredient.hpp @@ -23,7 +23,7 @@ namespace MWClass ///< Generate action for activation virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; + MWWorld::ContainerStore& containerStore) const; ///< Insert into a containe virtual std::string getScript (const MWWorld::Ptr& ptr) const; diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index 2c50472ac..dd3f4c922 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -90,7 +90,7 @@ namespace MWClass } void Light::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const + MWWorld::ContainerStore& containerStore) const { insertIntoContainerStore (ptr, containerStore.lights); } diff --git a/apps/openmw/mwclass/light.hpp b/apps/openmw/mwclass/light.hpp index 7df82ae5d..aa5c1d544 100644 --- a/apps/openmw/mwclass/light.hpp +++ b/apps/openmw/mwclass/light.hpp @@ -28,7 +28,7 @@ namespace MWClass ///< Generate action for activation virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; + MWWorld::ContainerStore& containerStore) const; ///< Insert into a containe virtual std::string getScript (const MWWorld::Ptr& ptr) const; diff --git a/apps/openmw/mwclass/lockpick.cpp b/apps/openmw/mwclass/lockpick.cpp index 67756f23c..1bfbd553f 100644 --- a/apps/openmw/mwclass/lockpick.cpp +++ b/apps/openmw/mwclass/lockpick.cpp @@ -61,7 +61,7 @@ namespace MWClass } void Lockpick::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const + MWWorld::ContainerStore& containerStore) const { insertIntoContainerStore (ptr, containerStore.lockpicks); } diff --git a/apps/openmw/mwclass/lockpick.hpp b/apps/openmw/mwclass/lockpick.hpp index 074a07c93..35250f486 100644 --- a/apps/openmw/mwclass/lockpick.hpp +++ b/apps/openmw/mwclass/lockpick.hpp @@ -23,7 +23,7 @@ namespace MWClass ///< Generate action for activation virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; + MWWorld::ContainerStore& containerStore) const; ///< Insert into a containe virtual std::string getScript (const MWWorld::Ptr& ptr) const; diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index 81e018d96..8d7e39fe5 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -60,7 +60,7 @@ namespace MWClass } void Miscellaneous::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const + MWWorld::ContainerStore& containerStore) const { insertIntoContainerStore (ptr, containerStore.miscItems); } diff --git a/apps/openmw/mwclass/misc.hpp b/apps/openmw/mwclass/misc.hpp index cb1858315..7b586e183 100644 --- a/apps/openmw/mwclass/misc.hpp +++ b/apps/openmw/mwclass/misc.hpp @@ -23,7 +23,7 @@ namespace MWClass ///< Generate action for activation virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; + MWWorld::ContainerStore& containerStore) const; ///< Insert into a containe virtual std::string getScript (const MWWorld::Ptr& ptr) const; diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index d94920041..cc7daa83e 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -29,7 +29,7 @@ namespace MWMechanics::NpcStats mNpcStats; MWMechanics::CreatureStats mCreatureStats; MWMechanics::Movement mMovement; - MWWorld::ContainerStore mContainerStore; + MWWorld::ContainerStore mContainerStore; virtual MWWorld::CustomData *clone() const; }; @@ -156,7 +156,7 @@ namespace MWClass return boost::shared_ptr (new MWWorld::ActionTalk (ptr)); } - MWWorld::ContainerStore& Npc::getContainerStore (const MWWorld::Ptr& ptr) + MWWorld::ContainerStore& Npc::getContainerStore (const MWWorld::Ptr& ptr) const { ensureCustomData (ptr); diff --git a/apps/openmw/mwclass/npc.hpp b/apps/openmw/mwclass/npc.hpp index bb9b131c9..bef417332 100644 --- a/apps/openmw/mwclass/npc.hpp +++ b/apps/openmw/mwclass/npc.hpp @@ -35,8 +35,7 @@ namespace MWClass virtual MWMechanics::NpcStats& getNpcStats (const MWWorld::Ptr& ptr) const; ///< Return NPC stats - virtual MWWorld::ContainerStore& getContainerStore ( - const MWWorld::Ptr& ptr) const; + virtual MWWorld::ContainerStore& getContainerStore (const MWWorld::Ptr& ptr) const; ///< Return container store virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp index 08047a2e8..71b3a1049 100644 --- a/apps/openmw/mwclass/potion.cpp +++ b/apps/openmw/mwclass/potion.cpp @@ -60,7 +60,7 @@ namespace MWClass } void Potion::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const + MWWorld::ContainerStore& containerStore) const { insertIntoContainerStore (ptr, containerStore.potions); } diff --git a/apps/openmw/mwclass/potion.hpp b/apps/openmw/mwclass/potion.hpp index e1a54db3c..28cb68d2c 100644 --- a/apps/openmw/mwclass/potion.hpp +++ b/apps/openmw/mwclass/potion.hpp @@ -23,7 +23,7 @@ namespace MWClass ///< Generate action for activation virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; + MWWorld::ContainerStore& containerStore) const; ///< Insert into a containe virtual std::string getScript (const MWWorld::Ptr& ptr) const; diff --git a/apps/openmw/mwclass/probe.cpp b/apps/openmw/mwclass/probe.cpp index a09a39e66..7af8f4b5e 100644 --- a/apps/openmw/mwclass/probe.cpp +++ b/apps/openmw/mwclass/probe.cpp @@ -20,7 +20,7 @@ namespace MWClass assert (ref->base != NULL); const std::string &model = ref->base->model; - + if (!model.empty()) { MWRender::Objects& objects = renderingInterface.getObjects(); @@ -59,7 +59,7 @@ namespace MWClass } void Probe::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const + MWWorld::ContainerStore& containerStore) const { insertIntoContainerStore (ptr, containerStore.probes); } diff --git a/apps/openmw/mwclass/probe.hpp b/apps/openmw/mwclass/probe.hpp index 287dd0475..1611ae279 100644 --- a/apps/openmw/mwclass/probe.hpp +++ b/apps/openmw/mwclass/probe.hpp @@ -23,7 +23,7 @@ namespace MWClass ///< Generate action for activation virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; + MWWorld::ContainerStore& containerStore) const; ///< Insert into a containe virtual std::string getScript (const MWWorld::Ptr& ptr) const; diff --git a/apps/openmw/mwclass/repair.cpp b/apps/openmw/mwclass/repair.cpp index 79c18d426..adb61687c 100644 --- a/apps/openmw/mwclass/repair.cpp +++ b/apps/openmw/mwclass/repair.cpp @@ -60,7 +60,7 @@ namespace MWClass } void Repair::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const + MWWorld::ContainerStore& containerStore) const { insertIntoContainerStore (ptr, containerStore.repairs); } diff --git a/apps/openmw/mwclass/repair.hpp b/apps/openmw/mwclass/repair.hpp index 174197d9a..bf094ab9f 100644 --- a/apps/openmw/mwclass/repair.hpp +++ b/apps/openmw/mwclass/repair.hpp @@ -23,7 +23,7 @@ namespace MWClass ///< Generate action for activation virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; + MWWorld::ContainerStore& containerStore) const; ///< Insert into a containe virtual std::string getScript (const MWWorld::Ptr& ptr) const; diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index f136aaccd..9b8fbb9fe 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -73,7 +73,7 @@ namespace MWClass } void Weapon::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const + MWWorld::ContainerStore& containerStore) const { insertIntoContainerStore (ptr, containerStore.weapons); } diff --git a/apps/openmw/mwclass/weapon.hpp b/apps/openmw/mwclass/weapon.hpp index 84c633ab3..a768bec95 100644 --- a/apps/openmw/mwclass/weapon.hpp +++ b/apps/openmw/mwclass/weapon.hpp @@ -29,7 +29,7 @@ namespace MWClass ///< Return item max health or throw an exception, if class does not have item health virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; + MWWorld::ContainerStore& containerStore) const; ///< Insert into a containe virtual std::string getScript (const MWWorld::Ptr& ptr) const; diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index b4f93576a..ec864d983 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -71,12 +71,12 @@ namespace MWWorld return boost::shared_ptr (new NullAction); } - ContainerStore& Class::getContainerStore (const Ptr& ptr) const + ContainerStore& Class::getContainerStore (const Ptr& ptr) const { throw std::runtime_error ("class does not have a container store"); } - void Class::insertIntoContainer (const Ptr& ptr, ContainerStore& containerStore) const + void Class::insertIntoContainer (const Ptr& ptr, ContainerStore& containerStore) const { throw std::runtime_error ("class does not support inserting into a container"); } diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index 706b11aaa..c5e271e7a 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -61,8 +61,6 @@ namespace MWWorld ///< Return ID of \a ptr or throw an exception, if class does not support ID retrieval /// (default implementation: throw an exception) - - virtual void insertObjectRendering (const Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; virtual void insertObject(const Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; ///< Add reference into a cell for rendering (default implementation: don't render anything). @@ -105,11 +103,11 @@ namespace MWWorld ///< Generate action for using via inventory menu (default implementation: return a /// null action). - virtual ContainerStore& getContainerStore (const Ptr& ptr) const; + virtual ContainerStore& getContainerStore (const Ptr& ptr) const; ///< Return container store or throw an exception, if class does not have a /// container store (default implementation: throw an exceoption) - virtual void insertIntoContainer (const Ptr& ptr, ContainerStore& containerStore) + virtual void insertIntoContainer (const Ptr& ptr, ContainerStore& containerStore) const; ///< Insert into a container or throw an exception, if class does not support inserting into /// a container. diff --git a/apps/openmw/mwworld/containerstore.hpp b/apps/openmw/mwworld/containerstore.hpp index 971a79c15..55bfc7ddb 100644 --- a/apps/openmw/mwworld/containerstore.hpp +++ b/apps/openmw/mwworld/containerstore.hpp @@ -3,23 +3,24 @@ #include +#include "refdata.hpp" + namespace MWWorld { - template struct ContainerStore { - ESMS::CellRefList potions; - ESMS::CellRefList appas; - ESMS::CellRefList armors; - ESMS::CellRefList books; - ESMS::CellRefList clothes; - ESMS::CellRefList ingreds; - ESMS::CellRefList lights; - ESMS::CellRefList lockpicks; - ESMS::CellRefList miscItems; - ESMS::CellRefList probes; - ESMS::CellRefList repairs; - ESMS::CellRefList weapons; + ESMS::CellRefList potions; + ESMS::CellRefList appas; + ESMS::CellRefList armors; + ESMS::CellRefList books; + ESMS::CellRefList clothes; + ESMS::CellRefList ingreds; + ESMS::CellRefList lights; + ESMS::CellRefList lockpicks; + ESMS::CellRefList miscItems; + ESMS::CellRefList probes; + ESMS::CellRefList repairs; + ESMS::CellRefList weapons; }; } diff --git a/apps/openmw/mwworld/containerutil.cpp b/apps/openmw/mwworld/containerutil.cpp index 7c7e5e5e8..ddcf8ad5e 100644 --- a/apps/openmw/mwworld/containerutil.cpp +++ b/apps/openmw/mwworld/containerutil.cpp @@ -24,7 +24,7 @@ namespace namespace MWWorld { void listItemsInContainer (const std::string& id, - ContainerStore& containerStore, + ContainerStore& containerStore, const ESMS::ESMStore& store, std::vector& list) { listItemsInContainerImp (id, containerStore.potions, store.potions, list); diff --git a/apps/openmw/mwworld/containerutil.hpp b/apps/openmw/mwworld/containerutil.hpp index 21e770404..b7d0c8ea2 100644 --- a/apps/openmw/mwworld/containerutil.hpp +++ b/apps/openmw/mwworld/containerutil.hpp @@ -8,11 +8,10 @@ #include "containerstore.hpp" #include "ptr.hpp" -#include "refdata.hpp" namespace MWWorld { - void listItemsInContainer (const std::string& id, ContainerStore& containerStore, + void listItemsInContainer (const std::string& id, ContainerStore& containerStore, const ESMS::ESMStore& store, std::vector& list); ///< append all references with the given id to list. } From e3e6b3809f8404ddc3cec4bcb8f545a0e8e6af46 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 20 Feb 2012 12:38:34 +0100 Subject: [PATCH 02/11] added container store iterator (a.k.a. the most hilarious iterator I ever had the misfortune to write) --- apps/openmw/mwworld/containerstore.hpp | 95 +++++++++++++++++++++++++- 1 file changed, 94 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/containerstore.hpp b/apps/openmw/mwworld/containerstore.hpp index 55bfc7ddb..9fcdb99c6 100644 --- a/apps/openmw/mwworld/containerstore.hpp +++ b/apps/openmw/mwworld/containerstore.hpp @@ -4,11 +4,33 @@ #include #include "refdata.hpp" +#include "ptr.hpp" namespace MWWorld { - struct ContainerStore + class ContainerStoreIterator; + + class ContainerStore { + public: + + static const int Type_Potion = 0x0001; + static const int Type_Apparatus = 0x0002; + static const int Type_Armor = 0x0004; + static const int Type_Book = 0x0008; + static const int Type_Clothing = 0x0010; + static const int Type_Ingredient = 0x0020; + static const int Type_Light = 0x0040; + static const int Type_Lockpick = 0x0080; + static const int Type_Miscellaneous = 0x0100; + static const int Type_Probe = 0x0200; + static const int Type_Repair = 0x0400; + static const int Type_Weapon = 0x0800; + + static const int Type_Last = Type_Weapon; + + static const int Type_All = 0xffff; + ESMS::CellRefList potions; ESMS::CellRefList appas; ESMS::CellRefList armors; @@ -21,7 +43,78 @@ namespace MWWorld ESMS::CellRefList probes; ESMS::CellRefList repairs; ESMS::CellRefList weapons; + + ContainerStoreIterator begin (int mask = Type_All); + + ContainerStoreIterator end(); + + friend class ContainerStoreIterator; }; + + /// \brief Iteration over a subset of objects in a ContainerStore + /// + /// \note The iterator will automatically skip over deleted objects. + class ContainerStoreIterator + { + int mType; + int mMask; + ContainerStore *mContainer; + mutable Ptr mPtr; + + ESMS::CellRefList::List::iterator mPotion; + ESMS::CellRefList::List::iterator mApparatus; + ESMS::CellRefList::List::iterator mArmor; + ESMS::CellRefList::List::iterator mBook; + ESMS::CellRefList::List::iterator mClothing; + ESMS::CellRefList::List::iterator mIngredient; + ESMS::CellRefList::List::iterator mLight; + ESMS::CellRefList::List::iterator mLockpick; + ESMS::CellRefList::List::iterator mMiscellaneous; + ESMS::CellRefList::List::iterator mProbe; + ESMS::CellRefList::List::iterator mRepair; + ESMS::CellRefList::List::iterator mWeapon; + + private: + + ContainerStoreIterator(); + ///< End-iterator + + ContainerStoreIterator (int mask, ContainerStore *container); + ///< Begin-iterator + + void incType(); + + void nextType(); + + bool resetIterator(); + ///< Reset iterator for selected type. + /// + /// \return Type not empty? + + bool incIterator(); + ///< Increment iterator for selected type. + /// + /// \return reached the end? + + public: + + Ptr *operator->() const; + + Ptr operator*() const; + + ContainerStoreIterator& operator++(); + + ContainerStoreIterator operator++ (int); + + bool isEqual (const ContainerStoreIterator& iter) const; + + int getType() const; + + friend class ContainerStore; + }; + + bool operator== (const ContainerStoreIterator& left, const ContainerStoreIterator& right); + bool operator!= (const ContainerStoreIterator& left, const ContainerStoreIterator& right); } #endif From 4a16553acc483368ce63cbd11dbfe6c3943b9438 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 20 Feb 2012 12:44:17 +0100 Subject: [PATCH 03/11] replaced an include with a forward declaration --- apps/openmw/mwworld/class.cpp | 1 + apps/openmw/mwworld/class.hpp | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index ec864d983..774562c7c 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -7,6 +7,7 @@ #include "ptr.hpp" #include "nullaction.hpp" +#include "containerstore.hpp" namespace MWWorld { diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index c5e271e7a..68fa7f1f5 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -7,11 +7,11 @@ #include #include "action.hpp" -#include "containerstore.hpp" #include "refdata.hpp" -#include "../mwrender/renderinginterface.hpp" #include "physicssystem.hpp" +#include "../mwrender/renderinginterface.hpp" + namespace Ogre { class Vector3; @@ -33,6 +33,7 @@ namespace MWWorld { class Ptr; class Environment; + class ContainerStore; /// \brief Base class for referenceable esm records class Class From 1beaea011507be6997dd473c847bc294da320549 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 20 Feb 2012 14:14:39 +0100 Subject: [PATCH 04/11] forgot to add cone file --- apps/openmw/mwworld/containerstore.cpp | 273 +++++++++++++++++++++++++ 1 file changed, 273 insertions(+) create mode 100644 apps/openmw/mwworld/containerstore.cpp diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp new file mode 100644 index 000000000..60c5b0e1a --- /dev/null +++ b/apps/openmw/mwworld/containerstore.cpp @@ -0,0 +1,273 @@ + +#include "containerstore.hpp" + +#include + +MWWorld::ContainerStoreIterator MWWorld::ContainerStore::begin (int mask) +{ + return ContainerStoreIterator (mask, this); +} + +MWWorld::ContainerStoreIterator MWWorld::ContainerStore::end() +{ + return ContainerStoreIterator(); +} + + + +MWWorld::ContainerStoreIterator::ContainerStoreIterator() : mType (-1), mMask (0), mContainer (0) +{} + +MWWorld::ContainerStoreIterator::ContainerStoreIterator (int mask, ContainerStore *container) +: mType (0), mMask (mask), mContainer (container) +{ + nextType(); +} + +void MWWorld::ContainerStoreIterator::incType() +{ + if (mType==0) + mType = 1; + else if (mType!=-1) + { + mType <<= 1; + + if (mType>ContainerStore::Type_Last) + mType = -1; + } +} + +void MWWorld::ContainerStoreIterator::nextType() +{ + while (mType!=-1) + { + incType(); + + if (mType & mMask) + if (resetIterator()) + break; + } +} + +bool MWWorld::ContainerStoreIterator::resetIterator() +{ + switch (mType) + { + case ContainerStore::Type_Potion: + + mPotion = mContainer->potions.list.begin(); + return mPotion!=mContainer->potions.list.end(); + + case ContainerStore::Type_Apparatus: + + mApparatus = mContainer->appas.list.begin(); + return mApparatus!=mContainer->appas.list.end(); + + case ContainerStore::Type_Armor: + + mArmor = mContainer->armors.list.begin(); + return mArmor!=mContainer->armors.list.end(); + + case ContainerStore::Type_Book: + + mBook = mContainer->books.list.begin(); + return mBook!=mContainer->books.list.end(); + + case ContainerStore::Type_Clothing: + + mClothing = mContainer->clothes.list.begin(); + return mClothing!=mContainer->clothes.list.end(); + + case ContainerStore::Type_Ingredient: + + mIngredient = mContainer->ingreds.list.begin(); + return mIngredient!=mContainer->ingreds.list.end(); + + case ContainerStore::Type_Light: + + mLight = mContainer->lights.list.begin(); + return mLight!=mContainer->lights.list.end(); + + case ContainerStore::Type_Lockpick: + + mLockpick = mContainer->lockpicks.list.begin(); + return mLockpick!=mContainer->lockpicks.list.end(); + + case ContainerStore::Type_Miscellaneous: + + mMiscellaneous = mContainer->miscItems.list.begin(); + return mMiscellaneous!=mContainer->miscItems.list.end(); + + case ContainerStore::Type_Probe: + + mProbe = mContainer->probes.list.begin(); + return mProbe!=mContainer->probes.list.end(); + + case ContainerStore::Type_Repair: + + mRepair = mContainer->repairs.list.begin(); + return mRepair!=mContainer->repairs.list.end(); + + case ContainerStore::Type_Weapon: + + mWeapon = mContainer->weapons.list.begin(); + return mWeapon!=mContainer->weapons.list.end(); + } + + return false; +} + +bool MWWorld::ContainerStoreIterator::incIterator() +{ + switch (mType) + { + case ContainerStore::Type_Potion: + + ++mPotion; + return mPotion==mContainer->potions.list.end(); + + case ContainerStore::Type_Apparatus: + + ++mApparatus; + return mApparatus==mContainer->appas.list.end(); + + case ContainerStore::Type_Armor: + + ++mArmor; + return mArmor==mContainer->armors.list.end(); + + case ContainerStore::Type_Book: + + ++mBook; + return mBook==mContainer->books.list.end(); + + case ContainerStore::Type_Clothing: + + ++mClothing; + return mClothing==mContainer->clothes.list.end(); + + case ContainerStore::Type_Ingredient: + + ++mIngredient; + return mIngredient==mContainer->ingreds.list.end(); + + case ContainerStore::Type_Light: + + ++mLight; + return mLight==mContainer->lights.list.end(); + + case ContainerStore::Type_Lockpick: + + ++mLockpick; + return mLockpick==mContainer->lockpicks.list.end(); + + case ContainerStore::Type_Miscellaneous: + + ++mMiscellaneous; + return mMiscellaneous==mContainer->miscItems.list.end(); + + case ContainerStore::Type_Probe: + + ++mProbe; + return mProbe==mContainer->probes.list.end(); + + case ContainerStore::Type_Repair: + + ++mRepair; + return mRepair==mContainer->repairs.list.end(); + + case ContainerStore::Type_Weapon: + + ++mWeapon; + return mWeapon==mContainer->weapons.list.end(); + } + + return true; +} + +MWWorld::Ptr *MWWorld::ContainerStoreIterator::operator->() const +{ + mPtr = **this; + return &mPtr; +} + +MWWorld::Ptr MWWorld::ContainerStoreIterator::operator*() const +{ + switch (mType) + { + case ContainerStore::Type_Potion: return MWWorld::Ptr (&*mPotion, 0); + case ContainerStore::Type_Apparatus: return MWWorld::Ptr (&*mApparatus, 0); + case ContainerStore::Type_Armor: return MWWorld::Ptr (&*mArmor, 0); + case ContainerStore::Type_Book: return MWWorld::Ptr (&*mBook, 0); + case ContainerStore::Type_Clothing: return MWWorld::Ptr (&*mClothing, 0); + case ContainerStore::Type_Ingredient: return MWWorld::Ptr (&*mIngredient, 0); + case ContainerStore::Type_Light: return MWWorld::Ptr (&*mLight, 0); + case ContainerStore::Type_Lockpick: return MWWorld::Ptr (&*mLockpick, 0); + case ContainerStore::Type_Miscellaneous: return MWWorld::Ptr (&*mMiscellaneous, 0); + case ContainerStore::Type_Probe: return MWWorld::Ptr (&*mProbe, 0); + case ContainerStore::Type_Repair: return MWWorld::Ptr (&*mRepair, 0); + case ContainerStore::Type_Weapon: return MWWorld::Ptr (&*mWeapon, 0); + } + + return MWWorld::Ptr(); +} + +MWWorld::ContainerStoreIterator& MWWorld::ContainerStoreIterator::operator++() +{ + do + { + if (incIterator()) + nextType(); + } + while (mType!=-1 && !(**this).getRefData().getCount()); + + return *this; +} + +MWWorld::ContainerStoreIterator MWWorld::ContainerStoreIterator::operator++ (int) +{ + ContainerStoreIterator iter (*this); + ++*this; + return iter; +} + +bool MWWorld::ContainerStoreIterator::isEqual (const ContainerStoreIterator& iter) const +{ + assert (mContainer==iter.mContainer); + + if (mType!=iter.mType) + return false; + + switch (mType) + { + case ContainerStore::Type_Potion: return mPotion==iter.mPotion; + case ContainerStore::Type_Apparatus: return mApparatus==iter.mApparatus; + case ContainerStore::Type_Armor: return mArmor==iter.mArmor; + case ContainerStore::Type_Book: return mBook==iter.mBook; + case ContainerStore::Type_Clothing: return mClothing==iter.mClothing; + case ContainerStore::Type_Ingredient: return mIngredient==iter.mIngredient; + case ContainerStore::Type_Light: return mLight==iter.mLight; + case ContainerStore::Type_Lockpick: return mLockpick==iter.mLockpick; + case ContainerStore::Type_Miscellaneous: return mMiscellaneous==iter.mMiscellaneous; + case ContainerStore::Type_Probe: return mProbe==iter.mProbe; + case ContainerStore::Type_Repair: return mRepair==iter.mRepair; + case ContainerStore::Type_Weapon: return mWeapon==iter.mWeapon; + } + + return false; +} + +int MWWorld::ContainerStoreIterator::getType() const +{ + return mType; +} + +bool MWWorld::operator== (const ContainerStoreIterator& left, const ContainerStoreIterator& right) +{ + return left.isEqual (right); +} + +bool MWWorld::operator!= (const ContainerStoreIterator& left, const ContainerStoreIterator& right) +{ + return !(left==right); +} From b7ea110632a31c341bc8ff0b18e1e63cfebdeab4 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 23 Feb 2012 12:33:50 +0100 Subject: [PATCH 05/11] manually created objects were initialised incompletely --- apps/openmw/mwworld/manualref.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/openmw/mwworld/manualref.hpp b/apps/openmw/mwworld/manualref.hpp index b4d3f7007..f8bc7d983 100644 --- a/apps/openmw/mwworld/manualref.hpp +++ b/apps/openmw/mwworld/manualref.hpp @@ -82,6 +82,7 @@ namespace MWWorld // initialise ESM::CellRef& cellRef = mPtr.getCellRef(); + cellRef.refID = name; cellRef.refnum = -1; cellRef.scale = 1; cellRef.factIndex = 0; From e13e858c7a5bdc73ca559069f6f95438921124d7 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 23 Feb 2012 12:34:25 +0100 Subject: [PATCH 06/11] fixed container store iterator; new add function --- apps/openmw/mwworld/containerstore.cpp | 77 ++++++++++++++++++++++++-- apps/openmw/mwworld/containerstore.hpp | 18 +++++- 2 files changed, 90 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index 60c5b0e1a..54908deec 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -2,6 +2,8 @@ #include "containerstore.hpp" #include +#include +#include MWWorld::ContainerStoreIterator MWWorld::ContainerStore::begin (int mask) { @@ -10,12 +12,78 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::begin (int mask) MWWorld::ContainerStoreIterator MWWorld::ContainerStore::end() { - return ContainerStoreIterator(); + return ContainerStoreIterator (this); +} + +void MWWorld::ContainerStore::add (const Ptr& ptr) +{ + /// \todo implement item stocking + + switch (getType (ptr)) + { + case Type_Potion: potions.list.push_back (*ptr.get()); break; + case Type_Apparatus: appas.list.push_back (*ptr.get()); break; + case Type_Armor: armors.list.push_back (*ptr.get()); break; + case Type_Book: books.list.push_back (*ptr.get()); break; + case Type_Clothing: clothes.list.push_back (*ptr.get()); break; + case Type_Ingredient: ingreds.list.push_back (*ptr.get()); break; + case Type_Light: lights.list.push_back (*ptr.get()); break; + case Type_Lockpick: lockpicks.list.push_back (*ptr.get()); break; + case Type_Miscellaneous: miscItems.list.push_back (*ptr.get()); break; + case Type_Probe: probes.list.push_back (*ptr.get()); break; + case Type_Repair: repairs.list.push_back (*ptr.get()); break; + case Type_Weapon: weapons.list.push_back (*ptr.get()); break; + } +} + +int MWWorld::ContainerStore::getType (const Ptr& ptr) +{ + if (ptr.isEmpty()) + throw std::runtime_error ("can't put a non-existent object into a container"); + + if (ptr.getTypeName()==typeid (ESM::Potion).name()) + return Type_Potion; + + if (ptr.getTypeName()==typeid (ESM::Apparatus).name()) + return Type_Apparatus; + + if (ptr.getTypeName()==typeid (ESM::Armor).name()) + return Type_Armor; + + if (ptr.getTypeName()==typeid (ESM::Book).name()) + return Type_Book; + + if (ptr.getTypeName()==typeid (ESM::Clothing).name()) + return Type_Clothing; + + if (ptr.getTypeName()==typeid (ESM::Ingredient).name()) + return Type_Ingredient; + + if (ptr.getTypeName()==typeid (ESM::Light).name()) + return Type_Light; + + if (ptr.getTypeName()==typeid (ESM::Tool).name()) + return Type_Lockpick; + + if (ptr.getTypeName()==typeid (ESM::Miscellaneous).name()) + return Type_Miscellaneous; + + if (ptr.getTypeName()==typeid (ESM::Probe).name()) + return Type_Probe; + + if (ptr.getTypeName()==typeid (ESM::Repair).name()) + return Type_Repair; + + if (ptr.getTypeName()==typeid (ESM::Weapon).name()) + return Type_Weapon; + + throw std::runtime_error ( + "Object of type " + ptr.getTypeName() + " can not be placed into a container"); } - -MWWorld::ContainerStoreIterator::ContainerStoreIterator() : mType (-1), mMask (0), mContainer (0) +MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container) +: mType (-1), mMask (0), mContainer (container) {} MWWorld::ContainerStoreIterator::ContainerStoreIterator (int mask, ContainerStore *container) @@ -209,7 +277,7 @@ MWWorld::Ptr MWWorld::ContainerStoreIterator::operator*() const case ContainerStore::Type_Weapon: return MWWorld::Ptr (&*mWeapon, 0); } - return MWWorld::Ptr(); + throw std::runtime_error ("invalid pointer"); } MWWorld::ContainerStoreIterator& MWWorld::ContainerStoreIterator::operator++() @@ -252,6 +320,7 @@ bool MWWorld::ContainerStoreIterator::isEqual (const ContainerStoreIterator& ite case ContainerStore::Type_Probe: return mProbe==iter.mProbe; case ContainerStore::Type_Repair: return mRepair==iter.mRepair; case ContainerStore::Type_Weapon: return mWeapon==iter.mWeapon; + case -1: return true; } return false; diff --git a/apps/openmw/mwworld/containerstore.hpp b/apps/openmw/mwworld/containerstore.hpp index 9fcdb99c6..99091ff67 100644 --- a/apps/openmw/mwworld/containerstore.hpp +++ b/apps/openmw/mwworld/containerstore.hpp @@ -31,6 +31,8 @@ namespace MWWorld static const int Type_All = 0xffff; +// private: + ESMS::CellRefList potions; ESMS::CellRefList appas; ESMS::CellRefList armors; @@ -44,10 +46,24 @@ namespace MWWorld ESMS::CellRefList repairs; ESMS::CellRefList weapons; + public: + ContainerStoreIterator begin (int mask = Type_All); ContainerStoreIterator end(); + void add (const Ptr& ptr); + ///< Add the item pointed to by \a ptr to this container. + /// + /// \note The item pointed to is not required to exist beyond this function call. + /// + /// \attention Do not add items to an existing stack by increasing the count instead of + /// calling this function! + + static int getType (const Ptr& ptr); + ///< This function throws an exception, if ptr does not point to an object, that can be + /// put into a container. + friend class ContainerStoreIterator; }; @@ -76,7 +92,7 @@ namespace MWWorld private: - ContainerStoreIterator(); + ContainerStoreIterator (ContainerStore *container); ///< End-iterator ContainerStoreIterator (int mask, ContainerStore *container); From 1d551030d10633368a5fb3c5906673f7a7793bfa Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 23 Feb 2012 12:34:51 +0100 Subject: [PATCH 07/11] container related script instruction are using the new container interface now --- apps/openmw/mwscript/containerextensions.cpp | 53 +++++++------------- 1 file changed, 19 insertions(+), 34 deletions(-) diff --git a/apps/openmw/mwscript/containerextensions.cpp b/apps/openmw/mwscript/containerextensions.cpp index aef48ddec..a0aba5db9 100644 --- a/apps/openmw/mwscript/containerextensions.cpp +++ b/apps/openmw/mwscript/containerextensions.cpp @@ -11,7 +11,7 @@ #include "../mwworld/manualref.hpp" #include "../mwworld/class.hpp" -#include "../mwworld/containerutil.hpp" +#include "../mwworld/containerstore.hpp" #include "interpretercontext.hpp" #include "ref.hpp" @@ -45,8 +45,7 @@ namespace MWScript ref.getPtr().getRefData().setCount (count); - MWWorld::Class::get (ref.getPtr()).insertIntoContainer (ref.getPtr(), - MWWorld::Class::get (ptr).getContainerStore (ptr)); + MWWorld::Class::get (ptr).getContainerStore (ptr).add (ref.getPtr()); } }; @@ -59,25 +58,16 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - std::string item = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - std::vector list; - - MWWorld::listItemsInContainer (item, - MWWorld::Class::get (ptr).getContainerStore (ptr), - context.getWorld().getStore(), list); + MWWorld::ContainerStore& store = MWWorld::Class::get (ptr).getContainerStore (ptr); Interpreter::Type_Integer sum = 0; - for (std::vector::iterator iter (list.begin()); iter!=list.end(); - ++iter) - { - sum += iter->getRefData().getCount(); - } + for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end(); ++iter) + if (iter->getCellRef().refID==item) + sum += iter->getRefData().getCount(); runtime.push (sum); } @@ -92,9 +82,6 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - std::string item = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); @@ -104,25 +91,23 @@ namespace MWScript if (count<0) throw std::runtime_error ("second argument for RemoveItem must be non-negative"); - std::vector list; + MWWorld::ContainerStore& store = MWWorld::Class::get (ptr).getContainerStore (ptr); - MWWorld::listItemsInContainer (item, - MWWorld::Class::get (ptr).getContainerStore (ptr), - context.getWorld().getStore(), list); - - for (std::vector::iterator iter (list.begin()); - iter!=list.end() && count; + for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end() && count; ++iter) { - if (iter->getRefData().getCount()<=count) + if (iter->getCellRef().refID==item) { - count -= iter->getRefData().getCount(); - iter->getRefData().setCount (0); - } - else - { - iter->getRefData().setCount (iter->getRefData().getCount()-count); - count = 0; + if (iter->getRefData().getCount()<=count) + { + count -= iter->getRefData().getCount(); + iter->getRefData().setCount (0); + } + else + { + iter->getRefData().setCount (iter->getRefData().getCount()-count); + count = 0; + } } } From f39aa2a68dd6b115a6f6f0a89b4a39a1eccf7193 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 23 Feb 2012 12:38:25 +0100 Subject: [PATCH 08/11] changed take action to use the new container store interface --- apps/openmw/mwworld/actiontake.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwworld/actiontake.cpp b/apps/openmw/mwworld/actiontake.cpp index b318f0796..bbe954049 100644 --- a/apps/openmw/mwworld/actiontake.cpp +++ b/apps/openmw/mwworld/actiontake.cpp @@ -4,6 +4,7 @@ #include "class.hpp" #include "environment.hpp" #include "world.hpp" +#include "containerstore.hpp" namespace MWWorld { @@ -14,8 +15,7 @@ namespace MWWorld // insert into player's inventory MWWorld::Ptr player = environment.mWorld->getPtr ("player", true); - MWWorld::Class::get (mObject).insertIntoContainer (mObject, - MWWorld::Class::get (player).getContainerStore (player)); + MWWorld::Class::get (player).getContainerStore (player).add (mObject); // remove from world environment.mWorld->deleteObject (mObject); From 699246e54b9a34ec1962956f99489f03bd23b34e Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 23 Feb 2012 12:53:48 +0100 Subject: [PATCH 09/11] removed insertIntoContainer function from MWWorld::Class hierarchy --- apps/openmw/mwclass/apparatus.cpp | 8 -------- apps/openmw/mwclass/apparatus.hpp | 4 ---- apps/openmw/mwclass/armor.cpp | 8 -------- apps/openmw/mwclass/armor.hpp | 4 ---- apps/openmw/mwclass/book.cpp | 8 -------- apps/openmw/mwclass/book.hpp | 4 ---- apps/openmw/mwclass/clothing.cpp | 8 -------- apps/openmw/mwclass/clothing.hpp | 4 ---- apps/openmw/mwclass/ingredient.cpp | 8 -------- apps/openmw/mwclass/ingredient.hpp | 4 ---- apps/openmw/mwclass/light.cpp | 8 -------- apps/openmw/mwclass/light.hpp | 4 ---- apps/openmw/mwclass/lockpick.cpp | 8 -------- apps/openmw/mwclass/lockpick.hpp | 4 ---- apps/openmw/mwclass/misc.cpp | 8 -------- apps/openmw/mwclass/misc.hpp | 4 ---- apps/openmw/mwclass/potion.cpp | 8 -------- apps/openmw/mwclass/potion.hpp | 4 ---- apps/openmw/mwclass/probe.cpp | 7 ------- apps/openmw/mwclass/probe.hpp | 4 ---- apps/openmw/mwclass/repair.cpp | 8 -------- apps/openmw/mwclass/repair.hpp | 4 ---- apps/openmw/mwclass/weapon.cpp | 8 -------- apps/openmw/mwclass/weapon.hpp | 4 ---- apps/openmw/mwworld/class.cpp | 5 ----- apps/openmw/mwworld/class.hpp | 5 ----- 26 files changed, 153 deletions(-) diff --git a/apps/openmw/mwclass/apparatus.cpp b/apps/openmw/mwclass/apparatus.cpp index 77819a97c..da7ff8696 100644 --- a/apps/openmw/mwclass/apparatus.cpp +++ b/apps/openmw/mwclass/apparatus.cpp @@ -10,8 +10,6 @@ #include "../mwrender/objects.hpp" -#include "containerutil.hpp" - namespace MWClass { void Apparatus::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const @@ -59,12 +57,6 @@ namespace MWClass new MWWorld::ActionTake (ptr)); } - void Apparatus::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const - { - insertIntoContainerStore (ptr, containerStore.appas); - } - std::string Apparatus::getScript (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/apparatus.hpp b/apps/openmw/mwclass/apparatus.hpp index 95bcbd38b..86223cf60 100644 --- a/apps/openmw/mwclass/apparatus.hpp +++ b/apps/openmw/mwclass/apparatus.hpp @@ -22,10 +22,6 @@ namespace MWClass const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; ///< Generate action for activation - virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; - ///< Insert into a containe - virtual std::string getScript (const MWWorld::Ptr& ptr) const; ///< Return name of the script attached to ptr diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index f62167d4f..3cdf63119 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -10,8 +10,6 @@ #include "../mwrender/objects.hpp" -#include "containerutil.hpp" - namespace MWClass { void Armor::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const @@ -71,12 +69,6 @@ namespace MWClass return ref->base->data.health; } - void Armor::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const - { - insertIntoContainerStore (ptr, containerStore.armors); - } - std::string Armor::getScript (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/armor.hpp b/apps/openmw/mwclass/armor.hpp index 0950e0744..060bc364e 100644 --- a/apps/openmw/mwclass/armor.hpp +++ b/apps/openmw/mwclass/armor.hpp @@ -28,10 +28,6 @@ namespace MWClass virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const; ///< Return item max health or throw an exception, if class does not have item health - virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; - ///< Insert into a containe - virtual std::string getScript (const MWWorld::Ptr& ptr) const; ///< Return name of the script attached to ptr diff --git a/apps/openmw/mwclass/book.cpp b/apps/openmw/mwclass/book.cpp index 2f3d1dcfa..576e521ee 100644 --- a/apps/openmw/mwclass/book.cpp +++ b/apps/openmw/mwclass/book.cpp @@ -10,8 +10,6 @@ #include "../mwrender/objects.hpp" -#include "containerutil.hpp" - namespace MWClass { void Book::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const @@ -61,12 +59,6 @@ namespace MWClass new MWWorld::ActionTake (ptr)); } - void Book::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const - { - insertIntoContainerStore (ptr, containerStore.books); - } - std::string Book::getScript (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/book.hpp b/apps/openmw/mwclass/book.hpp index 41cf5ba4a..12dc27bb2 100644 --- a/apps/openmw/mwclass/book.hpp +++ b/apps/openmw/mwclass/book.hpp @@ -22,10 +22,6 @@ namespace MWClass const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; ///< Generate action for activation - virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; - ///< Insert into a containe - virtual std::string getScript (const MWWorld::Ptr& ptr) const; ///< Return name of the script attached to ptr diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp index c9d7f0b06..88c43d82c 100644 --- a/apps/openmw/mwclass/clothing.cpp +++ b/apps/openmw/mwclass/clothing.cpp @@ -10,8 +10,6 @@ #include "../mwrender/objects.hpp" -#include "containerutil.hpp" - namespace MWClass { void Clothing::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const @@ -59,12 +57,6 @@ namespace MWClass new MWWorld::ActionTake (ptr)); } - void Clothing::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const - { - insertIntoContainerStore (ptr, containerStore.clothes); - } - std::string Clothing::getScript (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/clothing.hpp b/apps/openmw/mwclass/clothing.hpp index 25ba3456c..606aba9e0 100644 --- a/apps/openmw/mwclass/clothing.hpp +++ b/apps/openmw/mwclass/clothing.hpp @@ -22,10 +22,6 @@ namespace MWClass const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; ///< Generate action for activation - virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; - ///< Insert into a containe - virtual std::string getScript (const MWWorld::Ptr& ptr) const; ///< Return name of the script attached to ptr diff --git a/apps/openmw/mwclass/ingredient.cpp b/apps/openmw/mwclass/ingredient.cpp index 3a7594496..d00e4592d 100644 --- a/apps/openmw/mwclass/ingredient.cpp +++ b/apps/openmw/mwclass/ingredient.cpp @@ -10,8 +10,6 @@ #include "../mwrender/objects.hpp" -#include "containerutil.hpp" - namespace MWClass { void Ingredient::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const @@ -57,12 +55,6 @@ namespace MWClass new MWWorld::ActionTake (ptr)); } - void Ingredient::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const - { - insertIntoContainerStore (ptr, containerStore.ingreds); - } - std::string Ingredient::getScript (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/ingredient.hpp b/apps/openmw/mwclass/ingredient.hpp index 60cb21fac..92d2c4eef 100644 --- a/apps/openmw/mwclass/ingredient.hpp +++ b/apps/openmw/mwclass/ingredient.hpp @@ -22,10 +22,6 @@ namespace MWClass const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; ///< Generate action for activation - virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; - ///< Insert into a containe - virtual std::string getScript (const MWWorld::Ptr& ptr) const; ///< Return name of the script attached to ptr diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index dd3f4c922..03ad6b097 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -14,8 +14,6 @@ #include "../mwrender/objects.hpp" -#include "containerutil.hpp" - namespace MWClass { void Light::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const @@ -89,12 +87,6 @@ namespace MWClass new MWWorld::ActionTake (ptr)); } - void Light::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const - { - insertIntoContainerStore (ptr, containerStore.lights); - } - std::string Light::getScript (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/light.hpp b/apps/openmw/mwclass/light.hpp index aa5c1d544..c9940d0a5 100644 --- a/apps/openmw/mwclass/light.hpp +++ b/apps/openmw/mwclass/light.hpp @@ -27,10 +27,6 @@ namespace MWClass const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; ///< Generate action for activation - virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; - ///< Insert into a containe - virtual std::string getScript (const MWWorld::Ptr& ptr) const; ///< Return name of the script attached to ptr diff --git a/apps/openmw/mwclass/lockpick.cpp b/apps/openmw/mwclass/lockpick.cpp index 1bfbd553f..98c05a1b3 100644 --- a/apps/openmw/mwclass/lockpick.cpp +++ b/apps/openmw/mwclass/lockpick.cpp @@ -10,8 +10,6 @@ #include "../mwrender/objects.hpp" -#include "containerutil.hpp" - namespace MWClass { void Lockpick::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const @@ -60,12 +58,6 @@ namespace MWClass new MWWorld::ActionTake (ptr)); } - void Lockpick::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const - { - insertIntoContainerStore (ptr, containerStore.lockpicks); - } - std::string Lockpick::getScript (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/lockpick.hpp b/apps/openmw/mwclass/lockpick.hpp index 35250f486..9cbfa0d23 100644 --- a/apps/openmw/mwclass/lockpick.hpp +++ b/apps/openmw/mwclass/lockpick.hpp @@ -22,10 +22,6 @@ namespace MWClass const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; ///< Generate action for activation - virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; - ///< Insert into a containe - virtual std::string getScript (const MWWorld::Ptr& ptr) const; ///< Return name of the script attached to ptr diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index 8d7e39fe5..8dde84be9 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -10,8 +10,6 @@ #include "../mwrender/objects.hpp" -#include "containerutil.hpp" - namespace MWClass { void Miscellaneous::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const @@ -59,12 +57,6 @@ namespace MWClass new MWWorld::ActionTake (ptr)); } - void Miscellaneous::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const - { - insertIntoContainerStore (ptr, containerStore.miscItems); - } - std::string Miscellaneous::getScript (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/misc.hpp b/apps/openmw/mwclass/misc.hpp index 7b586e183..de01a64f4 100644 --- a/apps/openmw/mwclass/misc.hpp +++ b/apps/openmw/mwclass/misc.hpp @@ -22,10 +22,6 @@ namespace MWClass const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; ///< Generate action for activation - virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; - ///< Insert into a containe - virtual std::string getScript (const MWWorld::Ptr& ptr) const; ///< Return name of the script attached to ptr diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp index 71b3a1049..c57c18fd1 100644 --- a/apps/openmw/mwclass/potion.cpp +++ b/apps/openmw/mwclass/potion.cpp @@ -10,8 +10,6 @@ #include "../mwrender/objects.hpp" -#include "containerutil.hpp" - namespace MWClass { void Potion::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const @@ -59,12 +57,6 @@ namespace MWClass new MWWorld::ActionTake (ptr)); } - void Potion::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const - { - insertIntoContainerStore (ptr, containerStore.potions); - } - std::string Potion::getScript (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/potion.hpp b/apps/openmw/mwclass/potion.hpp index 28cb68d2c..fd78bba53 100644 --- a/apps/openmw/mwclass/potion.hpp +++ b/apps/openmw/mwclass/potion.hpp @@ -22,10 +22,6 @@ namespace MWClass const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; ///< Generate action for activation - virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; - ///< Insert into a containe - virtual std::string getScript (const MWWorld::Ptr& ptr) const; ///< Return name of the script attached to ptr diff --git a/apps/openmw/mwclass/probe.cpp b/apps/openmw/mwclass/probe.cpp index 7af8f4b5e..de024e430 100644 --- a/apps/openmw/mwclass/probe.cpp +++ b/apps/openmw/mwclass/probe.cpp @@ -8,7 +8,6 @@ #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" -#include "containerutil.hpp" #include "../mwrender/objects.hpp" namespace MWClass @@ -58,12 +57,6 @@ namespace MWClass new MWWorld::ActionTake (ptr)); } - void Probe::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const - { - insertIntoContainerStore (ptr, containerStore.probes); - } - std::string Probe::getScript (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/probe.hpp b/apps/openmw/mwclass/probe.hpp index 1611ae279..3f2bfed5b 100644 --- a/apps/openmw/mwclass/probe.hpp +++ b/apps/openmw/mwclass/probe.hpp @@ -22,10 +22,6 @@ namespace MWClass const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; ///< Generate action for activation - virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; - ///< Insert into a containe - virtual std::string getScript (const MWWorld::Ptr& ptr) const; ///< Return name of the script attached to ptr diff --git a/apps/openmw/mwclass/repair.cpp b/apps/openmw/mwclass/repair.cpp index adb61687c..f831b6b50 100644 --- a/apps/openmw/mwclass/repair.cpp +++ b/apps/openmw/mwclass/repair.cpp @@ -10,8 +10,6 @@ #include "../mwrender/objects.hpp" -#include "containerutil.hpp" - namespace MWClass { void Repair::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const @@ -59,12 +57,6 @@ namespace MWClass new MWWorld::ActionTake (ptr)); } - void Repair::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const - { - insertIntoContainerStore (ptr, containerStore.repairs); - } - std::string Repair::getScript (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/repair.hpp b/apps/openmw/mwclass/repair.hpp index bf094ab9f..a5864ab35 100644 --- a/apps/openmw/mwclass/repair.hpp +++ b/apps/openmw/mwclass/repair.hpp @@ -22,10 +22,6 @@ namespace MWClass const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; ///< Generate action for activation - virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; - ///< Insert into a containe - virtual std::string getScript (const MWWorld::Ptr& ptr) const; ///< Return name of the script attached to ptr diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index 9b8fbb9fe..90fd3e33b 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -10,8 +10,6 @@ #include "../mwrender/objects.hpp" -#include "containerutil.hpp" - namespace MWClass { void Weapon::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const @@ -72,12 +70,6 @@ namespace MWClass return ref->base->data.health; } - void Weapon::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const - { - insertIntoContainerStore (ptr, containerStore.weapons); - } - std::string Weapon::getScript (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/weapon.hpp b/apps/openmw/mwclass/weapon.hpp index a768bec95..b056249b9 100644 --- a/apps/openmw/mwclass/weapon.hpp +++ b/apps/openmw/mwclass/weapon.hpp @@ -28,10 +28,6 @@ namespace MWClass virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const; ///< Return item max health or throw an exception, if class does not have item health - virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; - ///< Insert into a containe - virtual std::string getScript (const MWWorld::Ptr& ptr) const; ///< Return name of the script attached to ptr diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index 774562c7c..641da73e1 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -77,11 +77,6 @@ namespace MWWorld throw std::runtime_error ("class does not have a container store"); } - void Class::insertIntoContainer (const Ptr& ptr, ContainerStore& containerStore) const - { - throw std::runtime_error ("class does not support inserting into a container"); - } - void Class::lock (const Ptr& ptr, int lockLevel) const { throw std::runtime_error ("class does not support locking"); diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index 68fa7f1f5..9b6acb3ce 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -108,11 +108,6 @@ namespace MWWorld ///< Return container store or throw an exception, if class does not have a /// container store (default implementation: throw an exceoption) - virtual void insertIntoContainer (const Ptr& ptr, ContainerStore& containerStore) - const; - ///< Insert into a container or throw an exception, if class does not support inserting into - /// a container. - virtual void lock (const Ptr& ptr, int lockLevel) const; ///< Lock object (default implementation: throw an exception) From af23cc352e3f3e9a84d9c11cd2b2eb59ec8eeb0d Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 23 Feb 2012 12:58:12 +0100 Subject: [PATCH 10/11] more cleanup --- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/mwclass/containerutil.hpp | 28 ----------------- apps/openmw/mwworld/containerutil.cpp | 43 --------------------------- apps/openmw/mwworld/containerutil.hpp | 19 ------------ 4 files changed, 1 insertion(+), 91 deletions(-) delete mode 100644 apps/openmw/mwclass/containerutil.hpp delete mode 100644 apps/openmw/mwworld/containerutil.cpp delete mode 100644 apps/openmw/mwworld/containerutil.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index e16cba9d6..e9c49c3f6 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -45,7 +45,7 @@ add_openmw_dir (mwsound add_openmw_dir (mwworld refdata world physicssystem scene environment globals class action nullaction actionteleport - containerstore actiontalk actiontake containerstore manualref containerutil player cellfunctors + containerstore actiontalk actiontake manualref player cellfunctors cells localscripts customdata ) diff --git a/apps/openmw/mwclass/containerutil.hpp b/apps/openmw/mwclass/containerutil.hpp deleted file mode 100644 index 76bdf0236..000000000 --- a/apps/openmw/mwclass/containerutil.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef GAME_MWCLASS_CONTAINERUTIL_H -#define GAME_MWCLASS_CONTAINERUTIL_H - -#include - -#include "../mwworld/ptr.hpp" -#include "../mwworld/containerstore.hpp" - -namespace MWClass -{ - template - void insertIntoContainerStore (const MWWorld::Ptr& ptr, - ESMS::CellRefList& containerStore) - { - if (!ptr.isEmpty()) - { - // TODO check stacking - - ESMS::LiveCellRef cellRef(ptr.getCellRef(), ptr.get()->base); - cellRef.mData = ptr.getRefData(); - - containerStore.list.push_back (cellRef); - - } - } -} - -#endif diff --git a/apps/openmw/mwworld/containerutil.cpp b/apps/openmw/mwworld/containerutil.cpp deleted file mode 100644 index ddcf8ad5e..000000000 --- a/apps/openmw/mwworld/containerutil.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -#include "containerutil.hpp" - -namespace -{ - template - void listItemsInContainerImp (const std::string& id, - ESMS::CellRefList& containerStore, - const ESMS::RecListT& store, std::vector& list) - { - if (const T *record = store.search (id)) - { - for (typename ESMS::CellRefList::List::iterator iter - (containerStore.list.begin()); - iter!=containerStore.list.end(); ++iter) - { - if (iter->base==record) - list.push_back (MWWorld::Ptr (&*iter, 0)); - } - } - } -} - -namespace MWWorld -{ - void listItemsInContainer (const std::string& id, - ContainerStore& containerStore, - const ESMS::ESMStore& store, std::vector& list) - { - listItemsInContainerImp (id, containerStore.potions, store.potions, list); - listItemsInContainerImp (id, containerStore.appas, store.appas, list); - listItemsInContainerImp (id, containerStore.armors, store.armors, list); - listItemsInContainerImp (id, containerStore.books, store.books, list); - listItemsInContainerImp (id, containerStore.clothes, store.clothes, list); - listItemsInContainerImp (id, containerStore.ingreds, store.ingreds, list); - listItemsInContainerImp (id, containerStore.lights, store.lights, list); - listItemsInContainerImp (id, containerStore.lockpicks, store.lockpicks, list); - listItemsInContainerImp (id, containerStore.miscItems, store.miscItems, list); - listItemsInContainerImp (id, containerStore.probes, store.probes, list); - listItemsInContainerImp (id, containerStore.repairs, store.repairs, list); - listItemsInContainerImp (id, containerStore.weapons, store.weapons, list); - } -} diff --git a/apps/openmw/mwworld/containerutil.hpp b/apps/openmw/mwworld/containerutil.hpp deleted file mode 100644 index b7d0c8ea2..000000000 --- a/apps/openmw/mwworld/containerutil.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef GAME_MWWORLD_CONTAINERUTIL_H -#define GAME_MWWORLD_CONTAINERUTIL_H - -#include -#include - -#include - -#include "containerstore.hpp" -#include "ptr.hpp" - -namespace MWWorld -{ - void listItemsInContainer (const std::string& id, ContainerStore& containerStore, - const ESMS::ESMStore& store, std::vector& list); - ///< append all references with the given id to list. -} - -#endif From 8f60d5b180053bef8830d385eb8e2b459a1f285f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 23 Feb 2012 13:01:53 +0100 Subject: [PATCH 11/11] made container store data members private --- apps/openmw/mwworld/containerstore.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/containerstore.hpp b/apps/openmw/mwworld/containerstore.hpp index 99091ff67..7263245f3 100644 --- a/apps/openmw/mwworld/containerstore.hpp +++ b/apps/openmw/mwworld/containerstore.hpp @@ -31,7 +31,7 @@ namespace MWWorld static const int Type_All = 0xffff; -// private: + private: ESMS::CellRefList potions; ESMS::CellRefList appas;