mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-25 11:26:37 +00:00 
			
		
		
		
	
						commit
						d3d6a69eea
					
				
					 52 changed files with 257 additions and 129 deletions
				
			
		|  | @ -66,9 +66,9 @@ namespace MWClass | ||||||
|         return ref->mBase->mName; |         return ref->mBase->mName; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     std::string Activator::getScript (const MWWorld::Ptr& ptr) const |     std::string Activator::getScript (const MWWorld::ConstPtr& ptr) const | ||||||
|     { |     { | ||||||
|         MWWorld::LiveCellRef<ESM::Activator> *ref = |         const MWWorld::LiveCellRef<ESM::Activator> *ref = | ||||||
|             ptr.get<ESM::Activator>(); |             ptr.get<ESM::Activator>(); | ||||||
| 
 | 
 | ||||||
|         return ref->mBase->mScript; |         return ref->mBase->mScript; | ||||||
|  |  | ||||||
|  | @ -31,7 +31,7 @@ namespace MWClass | ||||||
|             virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const; |             virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const; | ||||||
|             ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
 |             ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
 | ||||||
| 
 | 
 | ||||||
|             virtual std::string getScript (const MWWorld::Ptr& ptr) const; |             virtual std::string getScript (const MWWorld::ConstPtr& ptr) const; | ||||||
|             ///< Return name of the script attached to ptr
 |             ///< Return name of the script attached to ptr
 | ||||||
| 
 | 
 | ||||||
|             virtual boost::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const; |             virtual boost::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const; | ||||||
|  |  | ||||||
|  | @ -64,10 +64,9 @@ namespace MWClass | ||||||
|         return defaultItemActivate(ptr, actor); |         return defaultItemActivate(ptr, actor); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     std::string Apparatus::getScript (const MWWorld::Ptr& ptr) const |     std::string Apparatus::getScript (const MWWorld::ConstPtr& ptr) const | ||||||
|     { |     { | ||||||
|         MWWorld::LiveCellRef<ESM::Apparatus> *ref = |         const MWWorld::LiveCellRef<ESM::Apparatus> *ref = ptr.get<ESM::Apparatus>(); | ||||||
|             ptr.get<ESM::Apparatus>(); |  | ||||||
| 
 | 
 | ||||||
|         return ref->mBase->mScript; |         return ref->mBase->mScript; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -31,7 +31,7 @@ namespace MWClass | ||||||
|                 const MWWorld::Ptr& actor) const; |                 const MWWorld::Ptr& actor) const; | ||||||
|             ///< Generate action for activation
 |             ///< Generate action for activation
 | ||||||
| 
 | 
 | ||||||
|             virtual std::string getScript (const MWWorld::Ptr& ptr) const; |             virtual std::string getScript (const MWWorld::ConstPtr& ptr) const; | ||||||
|             ///< Return name of the script attached to ptr
 |             ///< Return name of the script attached to ptr
 | ||||||
| 
 | 
 | ||||||
|             virtual int getValue (const MWWorld::Ptr& ptr) const; |             virtual int getValue (const MWWorld::Ptr& ptr) const; | ||||||
|  |  | ||||||
|  | @ -83,10 +83,9 @@ namespace MWClass | ||||||
|         return ref->mBase->mData.mHealth; |         return ref->mBase->mData.mHealth; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     std::string Armor::getScript (const MWWorld::Ptr& ptr) const |     std::string Armor::getScript (const MWWorld::ConstPtr& ptr) const | ||||||
|     { |     { | ||||||
|         MWWorld::LiveCellRef<ESM::Armor> *ref = |         const MWWorld::LiveCellRef<ESM::Armor> *ref = ptr.get<ESM::Armor>(); | ||||||
|             ptr.get<ESM::Armor>(); |  | ||||||
| 
 | 
 | ||||||
|         return ref->mBase->mScript; |         return ref->mBase->mScript; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -36,7 +36,7 @@ namespace MWClass | ||||||
|             virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const; |             virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const; | ||||||
|             ///< Return item max health or throw an exception, if class does not have item health
 |             ///< Return item max health or throw an exception, if class does not have item health
 | ||||||
| 
 | 
 | ||||||
|             virtual std::string getScript (const MWWorld::Ptr& ptr) const; |             virtual std::string getScript (const MWWorld::ConstPtr& ptr) const; | ||||||
|             ///< Return name of the script attached to ptr
 |             ///< Return name of the script attached to ptr
 | ||||||
| 
 | 
 | ||||||
|             virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::Ptr& ptr) const; |             virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::Ptr& ptr) const; | ||||||
|  |  | ||||||
|  | @ -78,10 +78,9 @@ namespace MWClass | ||||||
|         return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionRead(ptr)); |         return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionRead(ptr)); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     std::string Book::getScript (const MWWorld::Ptr& ptr) const |     std::string Book::getScript (const MWWorld::ConstPtr& ptr) const | ||||||
|     { |     { | ||||||
|         MWWorld::LiveCellRef<ESM::Book> *ref = |         const MWWorld::LiveCellRef<ESM::Book> *ref = ptr.get<ESM::Book>(); | ||||||
|             ptr.get<ESM::Book>(); |  | ||||||
| 
 | 
 | ||||||
|         return ref->mBase->mScript; |         return ref->mBase->mScript; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -28,7 +28,7 @@ namespace MWClass | ||||||
|                 const MWWorld::Ptr& actor) const; |                 const MWWorld::Ptr& actor) const; | ||||||
|             ///< Generate action for activation
 |             ///< Generate action for activation
 | ||||||
| 
 | 
 | ||||||
|             virtual std::string getScript (const MWWorld::Ptr& ptr) const; |             virtual std::string getScript (const MWWorld::ConstPtr& ptr) const; | ||||||
|             ///< Return name of the script attached to ptr
 |             ///< Return name of the script attached to ptr
 | ||||||
| 
 | 
 | ||||||
|             virtual bool hasToolTip (const MWWorld::Ptr& ptr) const; |             virtual bool hasToolTip (const MWWorld::Ptr& ptr) const; | ||||||
|  |  | ||||||
|  | @ -66,10 +66,9 @@ namespace MWClass | ||||||
|         return defaultItemActivate(ptr, actor); |         return defaultItemActivate(ptr, actor); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     std::string Clothing::getScript (const MWWorld::Ptr& ptr) const |     std::string Clothing::getScript (const MWWorld::ConstPtr& ptr) const | ||||||
|     { |     { | ||||||
|         MWWorld::LiveCellRef<ESM::Clothing> *ref = |         const MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>(); | ||||||
|             ptr.get<ESM::Clothing>(); |  | ||||||
| 
 | 
 | ||||||
|         return ref->mBase->mScript; |         return ref->mBase->mScript; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -28,7 +28,7 @@ namespace MWClass | ||||||
|                 const MWWorld::Ptr& actor) const; |                 const MWWorld::Ptr& actor) const; | ||||||
|             ///< Generate action for activation
 |             ///< Generate action for activation
 | ||||||
| 
 | 
 | ||||||
|             virtual std::string getScript (const MWWorld::Ptr& ptr) const; |             virtual std::string getScript (const MWWorld::ConstPtr& ptr) const; | ||||||
|             ///< Return name of the script attached to ptr
 |             ///< Return name of the script attached to ptr
 | ||||||
| 
 | 
 | ||||||
|             virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::Ptr& ptr) const; |             virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::Ptr& ptr) const; | ||||||
|  |  | ||||||
|  | @ -209,10 +209,9 @@ namespace MWClass | ||||||
|         return ptr.getRefData().getCustomData()->asContainerCustomData().mContainerStore; |         return ptr.getRefData().getCustomData()->asContainerCustomData().mContainerStore; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     std::string Container::getScript (const MWWorld::Ptr& ptr) const |     std::string Container::getScript (const MWWorld::ConstPtr& ptr) const | ||||||
|     { |     { | ||||||
|         MWWorld::LiveCellRef<ESM::Container> *ref = |         const MWWorld::LiveCellRef<ESM::Container> *ref = ptr.get<ESM::Container>(); | ||||||
|             ptr.get<ESM::Container>(); |  | ||||||
| 
 | 
 | ||||||
|         return ref->mBase->mScript; |         return ref->mBase->mScript; | ||||||
|     } |     } | ||||||
|  | @ -299,6 +298,8 @@ namespace MWClass | ||||||
| 
 | 
 | ||||||
|     void Container::readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state) const |     void Container::readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state) const | ||||||
|     { |     { | ||||||
|  |         if (!state.mHasCustomState) | ||||||
|  |             return; | ||||||
|         const ESM::ContainerState& state2 = dynamic_cast<const ESM::ContainerState&> (state); |         const ESM::ContainerState& state2 = dynamic_cast<const ESM::ContainerState&> (state); | ||||||
| 
 | 
 | ||||||
|         if (!ptr.getRefData().getCustomData()) |         if (!ptr.getRefData().getCustomData()) | ||||||
|  | @ -312,13 +313,17 @@ namespace MWClass | ||||||
|             readState (state2.mInventory); |             readState (state2.mInventory); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     void Container::writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state) const |     void Container::writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state) const | ||||||
|     { |     { | ||||||
|         ESM::ContainerState& state2 = dynamic_cast<ESM::ContainerState&> (state); |         ESM::ContainerState& state2 = dynamic_cast<ESM::ContainerState&> (state); | ||||||
| 
 | 
 | ||||||
|         ensureCustomData (ptr); |         if (!ptr.getRefData().getCustomData()) | ||||||
|  |         { | ||||||
|  |             state.mHasCustomState = false; | ||||||
|  |             return; | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
|         dynamic_cast<ContainerCustomData&> (*ptr.getRefData().getCustomData()).mContainerStore. |         dynamic_cast<const ContainerCustomData&> (*ptr.getRefData().getCustomData()).mContainerStore. | ||||||
|             writeState (state2.mInventory); |             writeState (state2.mInventory); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -40,7 +40,7 @@ namespace MWClass | ||||||
|             virtual MWWorld::ContainerStore& getContainerStore (const MWWorld::Ptr& ptr) const; |             virtual MWWorld::ContainerStore& getContainerStore (const MWWorld::Ptr& ptr) const; | ||||||
|             ///< Return container store
 |             ///< Return container store
 | ||||||
| 
 | 
 | ||||||
|             virtual std::string getScript (const MWWorld::Ptr& ptr) const; |             virtual std::string getScript (const MWWorld::ConstPtr& ptr) const; | ||||||
|             ///< Return name of the script attached to ptr
 |             ///< Return name of the script attached to ptr
 | ||||||
| 
 | 
 | ||||||
|             virtual float getCapacity (const MWWorld::Ptr& ptr) const; |             virtual float getCapacity (const MWWorld::Ptr& ptr) const; | ||||||
|  | @ -63,7 +63,7 @@ namespace MWClass | ||||||
|                 const; |                 const; | ||||||
|             ///< Read additional state from \a state into \a ptr.
 |             ///< Read additional state from \a state into \a ptr.
 | ||||||
| 
 | 
 | ||||||
|             virtual void writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state) |             virtual void writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state) | ||||||
|                 const; |                 const; | ||||||
|             ///< Write additional state from \a ptr into \a state.
 |             ///< Write additional state from \a ptr into \a state.
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -444,9 +444,9 @@ namespace MWClass | ||||||
|         return isFlagBitSet(ptr, ESM::Creature::Weapon); |         return isFlagBitSet(ptr, ESM::Creature::Weapon); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     std::string Creature::getScript (const MWWorld::Ptr& ptr) const |     std::string Creature::getScript (const MWWorld::ConstPtr& ptr) const | ||||||
|     { |     { | ||||||
|         MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>(); |         const MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>(); | ||||||
| 
 | 
 | ||||||
|         return ref->mBase->mScript; |         return ref->mBase->mScript; | ||||||
|     } |     } | ||||||
|  | @ -724,7 +724,7 @@ namespace MWClass | ||||||
|         customData.mCreatureStats.readState (state2.mCreatureStats); |         customData.mCreatureStats.readState (state2.mCreatureStats); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     void Creature::writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state) |     void Creature::writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state) | ||||||
|         const |         const | ||||||
|     { |     { | ||||||
|         ESM::CreatureState& state2 = dynamic_cast<ESM::CreatureState&> (state); |         ESM::CreatureState& state2 = dynamic_cast<ESM::CreatureState&> (state); | ||||||
|  | @ -735,9 +735,7 @@ namespace MWClass | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         ensureCustomData (ptr); |         const CreatureCustomData& customData = dynamic_cast<const CreatureCustomData&>(*ptr.getRefData().getCustomData()); | ||||||
| 
 |  | ||||||
|         CreatureCustomData& customData = ptr.getRefData().getCustomData()->asCreatureCustomData(); |  | ||||||
| 
 | 
 | ||||||
|         customData.mContainerStore->writeState (state2.mInventory); |         customData.mContainerStore->writeState (state2.mInventory); | ||||||
|         customData.mCreatureStats.writeState (state2.mCreatureStats); |         customData.mCreatureStats.writeState (state2.mCreatureStats); | ||||||
|  |  | ||||||
|  | @ -74,7 +74,7 @@ namespace MWClass | ||||||
| 
 | 
 | ||||||
|             virtual bool hasInventoryStore (const MWWorld::Ptr &ptr) const; |             virtual bool hasInventoryStore (const MWWorld::Ptr &ptr) const; | ||||||
| 
 | 
 | ||||||
|             virtual std::string getScript (const MWWorld::Ptr& ptr) const; |             virtual std::string getScript (const MWWorld::ConstPtr& ptr) const; | ||||||
|             ///< Return name of the script attached to ptr
 |             ///< Return name of the script attached to ptr
 | ||||||
| 
 | 
 | ||||||
|             virtual float getCapacity (const MWWorld::Ptr& ptr) const; |             virtual float getCapacity (const MWWorld::Ptr& ptr) const; | ||||||
|  | @ -117,12 +117,10 @@ namespace MWClass | ||||||
|             /// Get a blood texture suitable for \a ptr (see Blood Texture 0-2 in Morrowind.ini)
 |             /// Get a blood texture suitable for \a ptr (see Blood Texture 0-2 in Morrowind.ini)
 | ||||||
|             virtual int getBloodTexture (const MWWorld::Ptr& ptr) const; |             virtual int getBloodTexture (const MWWorld::Ptr& ptr) const; | ||||||
| 
 | 
 | ||||||
|             virtual void readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state) |             virtual void readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state) const; | ||||||
|                 const; |  | ||||||
|             ///< Read additional state from \a state into \a ptr.
 |             ///< Read additional state from \a state into \a ptr.
 | ||||||
| 
 | 
 | ||||||
|             virtual void writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state) |             virtual void writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state) const; | ||||||
|                 const; |  | ||||||
|             ///< Write additional state from \a ptr into \a state.
 |             ///< Write additional state from \a ptr into \a state.
 | ||||||
| 
 | 
 | ||||||
|             virtual int getBaseGold(const MWWorld::Ptr& ptr) const; |             virtual int getBaseGold(const MWWorld::Ptr& ptr) const; | ||||||
|  |  | ||||||
|  | @ -104,6 +104,9 @@ namespace MWClass | ||||||
|     void CreatureLevList::readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state) |     void CreatureLevList::readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state) | ||||||
|         const |         const | ||||||
|     { |     { | ||||||
|  |         if (!state.mHasCustomState) | ||||||
|  |             return; | ||||||
|  | 
 | ||||||
|         const ESM::CreatureLevListState& state2 = dynamic_cast<const ESM::CreatureLevListState&> (state); |         const ESM::CreatureLevListState& state2 = dynamic_cast<const ESM::CreatureLevListState&> (state); | ||||||
| 
 | 
 | ||||||
|         ensureCustomData(ptr); |         ensureCustomData(ptr); | ||||||
|  | @ -112,13 +115,18 @@ namespace MWClass | ||||||
|         customData.mSpawn = state2.mSpawn; |         customData.mSpawn = state2.mSpawn; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     void CreatureLevList::writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state) |     void CreatureLevList::writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state) | ||||||
|         const |         const | ||||||
|     { |     { | ||||||
|         ESM::CreatureLevListState& state2 = dynamic_cast<ESM::CreatureLevListState&> (state); |         ESM::CreatureLevListState& state2 = dynamic_cast<ESM::CreatureLevListState&> (state); | ||||||
| 
 | 
 | ||||||
|         ensureCustomData(ptr); |         if (!ptr.getRefData().getCustomData()) | ||||||
|         CreatureLevListCustomData& customData = ptr.getRefData().getCustomData()->asCreatureLevListCustomData(); |         { | ||||||
|  |             state.mHasCustomState = false; | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         const CreatureLevListCustomData& customData = dynamic_cast<const CreatureLevListCustomData&>(*ptr.getRefData().getCustomData()); | ||||||
|         state2.mSpawnActorId = customData.mSpawnActorId; |         state2.mSpawnActorId = customData.mSpawnActorId; | ||||||
|         state2.mSpawn = customData.mSpawn; |         state2.mSpawn = customData.mSpawn; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -23,12 +23,10 @@ namespace MWClass | ||||||
|             virtual void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const; |             virtual void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const; | ||||||
|             ///< Add reference into a cell for rendering
 |             ///< Add reference into a cell for rendering
 | ||||||
| 
 | 
 | ||||||
|             virtual void readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state) |             virtual void readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state) const; | ||||||
|                 const; |  | ||||||
|             ///< Read additional state from \a state into \a ptr.
 |             ///< Read additional state from \a state into \a ptr.
 | ||||||
| 
 | 
 | ||||||
|             virtual void writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state) |             virtual void writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state) const; | ||||||
|                 const; |  | ||||||
|             ///< Write additional state from \a ptr into \a state.
 |             ///< Write additional state from \a ptr into \a state.
 | ||||||
| 
 | 
 | ||||||
|             virtual void respawn (const MWWorld::Ptr& ptr) const; |             virtual void respawn (const MWWorld::Ptr& ptr) const; | ||||||
|  |  | ||||||
|  | @ -217,10 +217,9 @@ namespace MWClass | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     std::string Door::getScript (const MWWorld::Ptr& ptr) const |     std::string Door::getScript (const MWWorld::ConstPtr& ptr) const | ||||||
|     { |     { | ||||||
|         MWWorld::LiveCellRef<ESM::Door> *ref = |         const MWWorld::LiveCellRef<ESM::Door> *ref = ptr.get<ESM::Door>(); | ||||||
|             ptr.get<ESM::Door>(); |  | ||||||
| 
 | 
 | ||||||
|         return ref->mBase->mScript; |         return ref->mBase->mScript; | ||||||
|     } |     } | ||||||
|  | @ -343,6 +342,8 @@ namespace MWClass | ||||||
| 
 | 
 | ||||||
|     void Door::readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state) const |     void Door::readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state) const | ||||||
|     { |     { | ||||||
|  |         if (!state.mHasCustomState) | ||||||
|  |             return; | ||||||
|         ensureCustomData(ptr); |         ensureCustomData(ptr); | ||||||
|         DoorCustomData& customData = ptr.getRefData().getCustomData()->asDoorCustomData(); |         DoorCustomData& customData = ptr.getRefData().getCustomData()->asDoorCustomData(); | ||||||
| 
 | 
 | ||||||
|  | @ -350,10 +351,14 @@ namespace MWClass | ||||||
|         customData.mDoorState = state2.mDoorState; |         customData.mDoorState = state2.mDoorState; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     void Door::writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state) const |     void Door::writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state) const | ||||||
|     { |     { | ||||||
|         ensureCustomData(ptr); |         if (!ptr.getRefData().getCustomData()) | ||||||
|         const DoorCustomData& customData = ptr.getRefData().getCustomData()->asDoorCustomData(); |         { | ||||||
|  |             state.mHasCustomState = false; | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |         const DoorCustomData& customData = dynamic_cast<const DoorCustomData&>(*ptr.getRefData().getCustomData()); | ||||||
| 
 | 
 | ||||||
|         ESM::DoorState& state2 = dynamic_cast<ESM::DoorState&>(state); |         ESM::DoorState& state2 = dynamic_cast<ESM::DoorState&>(state); | ||||||
|         state2.mDoorState = customData.mDoorState; |         state2.mDoorState = customData.mDoorState; | ||||||
|  |  | ||||||
|  | @ -49,7 +49,7 @@ namespace MWClass | ||||||
| 
 | 
 | ||||||
|             virtual bool canLock(const MWWorld::Ptr &ptr) const; |             virtual bool canLock(const MWWorld::Ptr &ptr) const; | ||||||
| 
 | 
 | ||||||
|             virtual std::string getScript (const MWWorld::Ptr& ptr) const; |             virtual std::string getScript (const MWWorld::ConstPtr& ptr) const; | ||||||
|             ///< Return name of the script attached to ptr
 |             ///< Return name of the script attached to ptr
 | ||||||
| 
 | 
 | ||||||
|             static void registerSelf(); |             static void registerSelf(); | ||||||
|  | @ -66,7 +66,7 @@ namespace MWClass | ||||||
|                 const; |                 const; | ||||||
|             ///< Read additional state from \a state into \a ptr.
 |             ///< Read additional state from \a state into \a ptr.
 | ||||||
| 
 | 
 | ||||||
|             virtual void writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state) |             virtual void writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state) | ||||||
|                 const; |                 const; | ||||||
|             ///< Write additional state from \a ptr into \a state.
 |             ///< Write additional state from \a ptr into \a state.
 | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|  | @ -70,10 +70,9 @@ namespace MWClass | ||||||
|         return defaultItemActivate(ptr, actor); |         return defaultItemActivate(ptr, actor); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     std::string Ingredient::getScript (const MWWorld::Ptr& ptr) const |     std::string Ingredient::getScript (const MWWorld::ConstPtr& ptr) const | ||||||
|     { |     { | ||||||
|         MWWorld::LiveCellRef<ESM::Ingredient> *ref = |         const MWWorld::LiveCellRef<ESM::Ingredient> *ref = ptr.get<ESM::Ingredient>(); | ||||||
|             ptr.get<ESM::Ingredient>(); |  | ||||||
| 
 | 
 | ||||||
|         return ref->mBase->mScript; |         return ref->mBase->mScript; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -34,7 +34,7 @@ namespace MWClass | ||||||
|             virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const; |             virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const; | ||||||
|             ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
 |             ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
 | ||||||
| 
 | 
 | ||||||
|             virtual std::string getScript (const MWWorld::Ptr& ptr) const; |             virtual std::string getScript (const MWWorld::ConstPtr& ptr) const; | ||||||
|             ///< Return name of the script attached to ptr
 |             ///< Return name of the script attached to ptr
 | ||||||
| 
 | 
 | ||||||
|             virtual int getValue (const MWWorld::Ptr& ptr) const; |             virtual int getValue (const MWWorld::Ptr& ptr) const; | ||||||
|  |  | ||||||
|  | @ -96,10 +96,9 @@ namespace MWClass | ||||||
|         return defaultItemActivate(ptr, actor); |         return defaultItemActivate(ptr, actor); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     std::string Light::getScript (const MWWorld::Ptr& ptr) const |     std::string Light::getScript (const MWWorld::ConstPtr& ptr) const | ||||||
|     { |     { | ||||||
|         MWWorld::LiveCellRef<ESM::Light> *ref = |         const MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>(); | ||||||
|             ptr.get<ESM::Light>(); |  | ||||||
| 
 | 
 | ||||||
|         return ref->mBase->mScript; |         return ref->mBase->mScript; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -34,7 +34,7 @@ namespace MWClass | ||||||
|                 const MWWorld::Ptr& actor) const; |                 const MWWorld::Ptr& actor) const; | ||||||
|             ///< Generate action for activation
 |             ///< Generate action for activation
 | ||||||
| 
 | 
 | ||||||
|             virtual std::string getScript (const MWWorld::Ptr& ptr) const; |             virtual std::string getScript (const MWWorld::ConstPtr& ptr) const; | ||||||
|             ///< Return name of the script attached to ptr
 |             ///< Return name of the script attached to ptr
 | ||||||
| 
 | 
 | ||||||
|             virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::Ptr& ptr) const; |             virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::Ptr& ptr) const; | ||||||
|  |  | ||||||
|  | @ -65,10 +65,9 @@ namespace MWClass | ||||||
|         return defaultItemActivate(ptr, actor); |         return defaultItemActivate(ptr, actor); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     std::string Lockpick::getScript (const MWWorld::Ptr& ptr) const |     std::string Lockpick::getScript (const MWWorld::ConstPtr& ptr) const | ||||||
|     { |     { | ||||||
|         MWWorld::LiveCellRef<ESM::Lockpick> *ref = |         const MWWorld::LiveCellRef<ESM::Lockpick> *ref = ptr.get<ESM::Lockpick>(); | ||||||
|             ptr.get<ESM::Lockpick>(); |  | ||||||
| 
 | 
 | ||||||
|         return ref->mBase->mScript; |         return ref->mBase->mScript; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -34,7 +34,7 @@ namespace MWClass | ||||||
|             virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const; |             virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const; | ||||||
|             ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
 |             ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
 | ||||||
| 
 | 
 | ||||||
|             virtual std::string getScript (const MWWorld::Ptr& ptr) const; |             virtual std::string getScript (const MWWorld::ConstPtr& ptr) const; | ||||||
|             ///< Return name of the script attached to ptr
 |             ///< Return name of the script attached to ptr
 | ||||||
| 
 | 
 | ||||||
|             virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::Ptr& ptr) const; |             virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::Ptr& ptr) const; | ||||||
|  |  | ||||||
|  | @ -78,10 +78,9 @@ namespace MWClass | ||||||
|         return defaultItemActivate(ptr, actor); |         return defaultItemActivate(ptr, actor); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     std::string Miscellaneous::getScript (const MWWorld::Ptr& ptr) const |     std::string Miscellaneous::getScript (const MWWorld::ConstPtr& ptr) const | ||||||
|     { |     { | ||||||
|         MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = |         const MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = ptr.get<ESM::Miscellaneous>(); | ||||||
|             ptr.get<ESM::Miscellaneous>(); |  | ||||||
| 
 | 
 | ||||||
|         return ref->mBase->mScript; |         return ref->mBase->mScript; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -34,7 +34,7 @@ namespace MWClass | ||||||
|             virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const; |             virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const; | ||||||
|             ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
 |             ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
 | ||||||
| 
 | 
 | ||||||
|             virtual std::string getScript (const MWWorld::Ptr& ptr) const; |             virtual std::string getScript (const MWWorld::ConstPtr& ptr) const; | ||||||
|             ///< Return name of the script attached to ptr
 |             ///< Return name of the script attached to ptr
 | ||||||
| 
 | 
 | ||||||
|             virtual int getValue (const MWWorld::Ptr& ptr) const; |             virtual int getValue (const MWWorld::Ptr& ptr) const; | ||||||
|  |  | ||||||
|  | @ -799,10 +799,9 @@ namespace MWClass | ||||||
|         return ptr.getRefData().getCustomData()->asNpcCustomData().mInventoryStore; |         return ptr.getRefData().getCustomData()->asNpcCustomData().mInventoryStore; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     std::string Npc::getScript (const MWWorld::Ptr& ptr) const |     std::string Npc::getScript (const MWWorld::ConstPtr& ptr) const | ||||||
|     { |     { | ||||||
|         MWWorld::LiveCellRef<ESM::NPC> *ref = |         const MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>(); | ||||||
|             ptr.get<ESM::NPC>(); |  | ||||||
| 
 | 
 | ||||||
|         return ref->mBase->mScript; |         return ref->mBase->mScript; | ||||||
|     } |     } | ||||||
|  | @ -1176,7 +1175,7 @@ namespace MWClass | ||||||
|         static_cast<MWMechanics::CreatureStats&> (customData.mNpcStats).readState (state2.mCreatureStats); |         static_cast<MWMechanics::CreatureStats&> (customData.mNpcStats).readState (state2.mCreatureStats); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     void Npc::writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state) |     void Npc::writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state) | ||||||
|         const |         const | ||||||
|     { |     { | ||||||
|         ESM::NpcState& state2 = dynamic_cast<ESM::NpcState&> (state); |         ESM::NpcState& state2 = dynamic_cast<ESM::NpcState&> (state); | ||||||
|  | @ -1187,9 +1186,7 @@ namespace MWClass | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         ensureCustomData (ptr); |         const NpcCustomData& customData = dynamic_cast<const NpcCustomData&>(*ptr.getRefData().getCustomData()); | ||||||
| 
 |  | ||||||
|         NpcCustomData& customData = ptr.getRefData().getCustomData()->asNpcCustomData(); |  | ||||||
| 
 | 
 | ||||||
|         customData.mInventoryStore.writeState (state2.mInventory); |         customData.mInventoryStore.writeState (state2.mInventory); | ||||||
|         customData.mNpcStats.writeState (state2.mNpcStats); |         customData.mNpcStats.writeState (state2.mNpcStats); | ||||||
|  |  | ||||||
|  | @ -80,7 +80,7 @@ namespace MWClass | ||||||
|                 const MWWorld::Ptr& actor) const; |                 const MWWorld::Ptr& actor) const; | ||||||
|             ///< Generate action for activation
 |             ///< Generate action for activation
 | ||||||
| 
 | 
 | ||||||
|             virtual std::string getScript (const MWWorld::Ptr& ptr) const; |             virtual std::string getScript (const MWWorld::ConstPtr& ptr) const; | ||||||
|             ///< Return name of the script attached to ptr
 |             ///< Return name of the script attached to ptr
 | ||||||
| 
 | 
 | ||||||
|             virtual float getSpeed (const MWWorld::Ptr& ptr) const; |             virtual float getSpeed (const MWWorld::Ptr& ptr) const; | ||||||
|  | @ -145,7 +145,7 @@ namespace MWClass | ||||||
|                 const; |                 const; | ||||||
|             ///< Read additional state from \a state into \a ptr.
 |             ///< Read additional state from \a state into \a ptr.
 | ||||||
| 
 | 
 | ||||||
|             virtual void writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state) |             virtual void writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state) | ||||||
|                 const; |                 const; | ||||||
|             ///< Write additional state from \a ptr into \a state.
 |             ///< Write additional state from \a ptr into \a state.
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -68,9 +68,9 @@ namespace MWClass | ||||||
|         return defaultItemActivate(ptr, actor); |         return defaultItemActivate(ptr, actor); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     std::string Potion::getScript (const MWWorld::Ptr& ptr) const |     std::string Potion::getScript (const MWWorld::ConstPtr& ptr) const | ||||||
|     { |     { | ||||||
|         MWWorld::LiveCellRef<ESM::Potion> *ref = |         const MWWorld::LiveCellRef<ESM::Potion> *ref = | ||||||
|             ptr.get<ESM::Potion>(); |             ptr.get<ESM::Potion>(); | ||||||
| 
 | 
 | ||||||
|         return ref->mBase->mScript; |         return ref->mBase->mScript; | ||||||
|  |  | ||||||
|  | @ -34,7 +34,7 @@ namespace MWClass | ||||||
|             virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const; |             virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const; | ||||||
|             ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
 |             ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
 | ||||||
| 
 | 
 | ||||||
|             virtual std::string getScript (const MWWorld::Ptr& ptr) const; |             virtual std::string getScript (const MWWorld::ConstPtr& ptr) const; | ||||||
|             ///< Return name of the script attached to ptr
 |             ///< Return name of the script attached to ptr
 | ||||||
| 
 | 
 | ||||||
|             virtual int getValue (const MWWorld::Ptr& ptr) const; |             virtual int getValue (const MWWorld::Ptr& ptr) const; | ||||||
|  |  | ||||||
|  | @ -64,9 +64,9 @@ namespace MWClass | ||||||
|         return defaultItemActivate(ptr, actor); |         return defaultItemActivate(ptr, actor); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     std::string Probe::getScript (const MWWorld::Ptr& ptr) const |     std::string Probe::getScript (const MWWorld::ConstPtr& ptr) const | ||||||
|     { |     { | ||||||
|         MWWorld::LiveCellRef<ESM::Probe> *ref = |         const MWWorld::LiveCellRef<ESM::Probe> *ref = | ||||||
|             ptr.get<ESM::Probe>(); |             ptr.get<ESM::Probe>(); | ||||||
| 
 | 
 | ||||||
|         return ref->mBase->mScript; |         return ref->mBase->mScript; | ||||||
|  |  | ||||||
|  | @ -34,7 +34,7 @@ namespace MWClass | ||||||
|             virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const; |             virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const; | ||||||
|             ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
 |             ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
 | ||||||
| 
 | 
 | ||||||
|             virtual std::string getScript (const MWWorld::Ptr& ptr) const; |             virtual std::string getScript (const MWWorld::ConstPtr& ptr) const; | ||||||
|             ///< Return name of the script attached to ptr
 |             ///< Return name of the script attached to ptr
 | ||||||
| 
 | 
 | ||||||
|             virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::Ptr& ptr) const; |             virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::Ptr& ptr) const; | ||||||
|  |  | ||||||
|  | @ -64,9 +64,9 @@ namespace MWClass | ||||||
|         return defaultItemActivate(ptr, actor); |         return defaultItemActivate(ptr, actor); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     std::string Repair::getScript (const MWWorld::Ptr& ptr) const |     std::string Repair::getScript (const MWWorld::ConstPtr& ptr) const | ||||||
|     { |     { | ||||||
|         MWWorld::LiveCellRef<ESM::Repair> *ref = |         const MWWorld::LiveCellRef<ESM::Repair> *ref = | ||||||
|             ptr.get<ESM::Repair>(); |             ptr.get<ESM::Repair>(); | ||||||
| 
 | 
 | ||||||
|         return ref->mBase->mScript; |         return ref->mBase->mScript; | ||||||
|  |  | ||||||
|  | @ -34,7 +34,7 @@ namespace MWClass | ||||||
|             virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const; |             virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr) const; | ||||||
|             ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
 |             ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
 | ||||||
| 
 | 
 | ||||||
|             virtual std::string getScript (const MWWorld::Ptr& ptr) const; |             virtual std::string getScript (const MWWorld::ConstPtr& ptr) const; | ||||||
|             ///< Return name of the script attached to ptr
 |             ///< Return name of the script attached to ptr
 | ||||||
| 
 | 
 | ||||||
|             virtual int getValue (const MWWorld::Ptr& ptr) const; |             virtual int getValue (const MWWorld::Ptr& ptr) const; | ||||||
|  |  | ||||||
|  | @ -84,9 +84,9 @@ namespace MWClass | ||||||
|         return ref->mBase->mData.mHealth; |         return ref->mBase->mData.mHealth; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     std::string Weapon::getScript (const MWWorld::Ptr& ptr) const |     std::string Weapon::getScript (const MWWorld::ConstPtr& ptr) const | ||||||
|     { |     { | ||||||
|         MWWorld::LiveCellRef<ESM::Weapon> *ref = |         const MWWorld::LiveCellRef<ESM::Weapon> *ref = | ||||||
|             ptr.get<ESM::Weapon>(); |             ptr.get<ESM::Weapon>(); | ||||||
| 
 | 
 | ||||||
|         return ref->mBase->mScript; |         return ref->mBase->mScript; | ||||||
|  |  | ||||||
|  | @ -40,7 +40,7 @@ namespace MWClass | ||||||
|             virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const; |             virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const; | ||||||
|             ///< Return item max health or throw an exception, if class does not have item health
 |             ///< Return item max health or throw an exception, if class does not have item health
 | ||||||
| 
 | 
 | ||||||
|             virtual std::string getScript (const MWWorld::Ptr& ptr) const; |             virtual std::string getScript (const MWWorld::ConstPtr& ptr) const; | ||||||
|             ///< Return name of the script attached to ptr
 |             ///< Return name of the script attached to ptr
 | ||||||
| 
 | 
 | ||||||
|             virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::Ptr& ptr) const; |             virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::Ptr& ptr) const; | ||||||
|  |  | ||||||
|  | @ -20,7 +20,7 @@ namespace MWRender | ||||||
|             MWWorld::Store<ESM::Land>::iterator it = esmStore.get<ESM::Land>().begin(); |             MWWorld::Store<ESM::Land>::iterator it = esmStore.get<ESM::Land>().begin(); | ||||||
|             for (; it != esmStore.get<ESM::Land>().end(); ++it) |             for (; it != esmStore.get<ESM::Land>().end(); ++it) | ||||||
|             { |             { | ||||||
|                 ESM::Land* land = const_cast<ESM::Land*>(&*it); // TODO: fix store interface
 |                 const ESM::Land* land = &*it; | ||||||
|                 land->loadData(ESM::Land::DATA_VCLR|ESM::Land::DATA_VHGT|ESM::Land::DATA_VNML|ESM::Land::DATA_VTEX); |                 land->loadData(ESM::Land::DATA_VCLR|ESM::Land::DATA_VHGT|ESM::Land::DATA_VNML|ESM::Land::DATA_VTEX); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  | @ -346,15 +346,15 @@ namespace MWWorld | ||||||
|         if (mState==State_Preloaded) |         if (mState==State_Preloaded) | ||||||
|             return std::binary_search (mIds.begin(), mIds.end(), id); |             return std::binary_search (mIds.begin(), mIds.end(), id); | ||||||
| 
 | 
 | ||||||
|         /// \todo address const-issues
 |  | ||||||
|         return searchConst (id).isEmpty(); |         return searchConst (id).isEmpty(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     template <typename PtrType> | ||||||
|     struct SearchVisitor |     struct SearchVisitor | ||||||
|     { |     { | ||||||
|         MWWorld::Ptr mFound; |         PtrType mFound; | ||||||
|         std::string mIdToFind; |         std::string mIdToFind; | ||||||
|         bool operator()(const MWWorld::Ptr& ptr) |         bool operator()(const PtrType& ptr) | ||||||
|         { |         { | ||||||
|             if (ptr.getCellRef().getRefId() == mIdToFind) |             if (ptr.getCellRef().getRefId() == mIdToFind) | ||||||
|             { |             { | ||||||
|  | @ -367,19 +367,18 @@ namespace MWWorld | ||||||
| 
 | 
 | ||||||
|     Ptr CellStore::search (const std::string& id) |     Ptr CellStore::search (const std::string& id) | ||||||
|     { |     { | ||||||
|         SearchVisitor searchVisitor; |         SearchVisitor<MWWorld::Ptr> searchVisitor; | ||||||
|         searchVisitor.mIdToFind = id; |         searchVisitor.mIdToFind = id; | ||||||
|         forEach(searchVisitor); |         forEach(searchVisitor); | ||||||
|         return searchVisitor.mFound; |         return searchVisitor.mFound; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     Ptr CellStore::searchConst (const std::string& id) const |     ConstPtr CellStore::searchConst (const std::string& id) const | ||||||
|     { |     { | ||||||
|         bool oldState = mHasState; |         SearchVisitor<MWWorld::ConstPtr> searchVisitor; | ||||||
|         /// \todo address const-issues
 |         searchVisitor.mIdToFind = id; | ||||||
|         Ptr result = const_cast<CellStore*>(this)->search(id); |         forEachConst(searchVisitor); | ||||||
|         const_cast<CellStore*>(this)->mHasState = oldState; |         return searchVisitor.mFound; | ||||||
|         return result; |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     Ptr CellStore::searchViaActorId (int id) |     Ptr CellStore::searchViaActorId (int id) | ||||||
|  |  | ||||||
|  | @ -214,10 +214,10 @@ namespace MWWorld | ||||||
|             /// containers.
 |             /// containers.
 | ||||||
|             /// @note Triggers CellStore hasState flag.
 |             /// @note Triggers CellStore hasState flag.
 | ||||||
| 
 | 
 | ||||||
|             Ptr searchConst (const std::string& id) const; |             ConstPtr searchConst (const std::string& id) const; | ||||||
|             ///< Will return an empty Ptr if cell is not loaded. Does not check references in
 |             ///< Will return an empty Ptr if cell is not loaded. Does not check references in
 | ||||||
|             /// containers.
 |             /// containers.
 | ||||||
|             /// @note Does not trigger CellStore hasState flag. Do not modify the returned Ptr!
 |             /// @note Does not trigger CellStore hasState flag.
 | ||||||
| 
 | 
 | ||||||
|             Ptr searchViaActorId (int id); |             Ptr searchViaActorId (int id); | ||||||
|             ///< Will return an empty Ptr if cell is not loaded.
 |             ///< Will return an empty Ptr if cell is not loaded.
 | ||||||
|  | @ -240,8 +240,9 @@ namespace MWWorld | ||||||
|             void preload (); |             void preload (); | ||||||
|             ///< Build ID list from content file.
 |             ///< Build ID list from content file.
 | ||||||
| 
 | 
 | ||||||
|             /// Call visitor (ref) for each reference. visitor must return a bool. Returning
 |             /// Call visitor (MWWorld::Ptr) for each reference. visitor must return a bool. Returning
 | ||||||
|             /// false will abort the iteration.
 |             /// false will abort the iteration.
 | ||||||
|  |             /// \note Prefer using forEachConst when possible.
 | ||||||
|             /// \attention This function also lists deleted (count 0) objects!
 |             /// \attention This function also lists deleted (count 0) objects!
 | ||||||
|             /// \return Iteration completed?
 |             /// \return Iteration completed?
 | ||||||
|             template<class Visitor> |             template<class Visitor> | ||||||
|  | @ -263,6 +264,28 @@ namespace MWWorld | ||||||
|                 return true; |                 return true; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|  |             /// Call visitor (MWWorld::ConstPtr) for each reference. visitor must return a bool. Returning
 | ||||||
|  |             /// false will abort the iteration.
 | ||||||
|  |             /// \attention This function also lists deleted (count 0) objects!
 | ||||||
|  |             /// \return Iteration completed?
 | ||||||
|  |             template<class Visitor> | ||||||
|  |             bool forEachConst (Visitor& visitor) const | ||||||
|  |             { | ||||||
|  |                 if (mState != State_Loaded) | ||||||
|  |                     return false; | ||||||
|  | 
 | ||||||
|  |                 for (unsigned int i=0; i<mMergedRefs.size(); ++i) | ||||||
|  |                 { | ||||||
|  |                     if (!isAccessible(mMergedRefs[i]->mData, mMergedRefs[i]->mRef)) | ||||||
|  |                         continue; | ||||||
|  | 
 | ||||||
|  |                     if (!visitor(MWWorld::ConstPtr(mMergedRefs[i], this))) | ||||||
|  |                         return false; | ||||||
|  |                 } | ||||||
|  |                 return true; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|             /// Call visitor (ref) for each reference of given type. visitor must return a bool. Returning
 |             /// Call visitor (ref) for each reference of given type. visitor must return a bool. Returning
 | ||||||
|             /// false will abort the iteration.
 |             /// false will abort the iteration.
 | ||||||
|             /// \attention This function also lists deleted (count 0) objects!
 |             /// \attention This function also lists deleted (count 0) objects!
 | ||||||
|  | @ -298,9 +321,6 @@ namespace MWWorld | ||||||
|                 return true; |                 return true; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             /// \todo add const version of forEach
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|             // NOTE: does not account for moved references
 |             // NOTE: does not account for moved references
 | ||||||
|             // Should be phased out when we have const version of forEach
 |             // Should be phased out when we have const version of forEach
 | ||||||
|             inline const CellRefList<ESM::Door>& getReadOnlyDoors() const |             inline const CellRefList<ESM::Door>& getReadOnlyDoors() const | ||||||
|  |  | ||||||
|  | @ -158,7 +158,7 @@ namespace MWWorld | ||||||
|         return -1; |         return -1; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     std::string Class::getScript (const Ptr& ptr) const |     std::string Class::getScript (const ConstPtr& ptr) const | ||||||
|     { |     { | ||||||
|         return ""; |         return ""; | ||||||
|     } |     } | ||||||
|  | @ -397,7 +397,7 @@ namespace MWWorld | ||||||
| 
 | 
 | ||||||
|     void Class::readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state) const {} |     void Class::readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state) const {} | ||||||
| 
 | 
 | ||||||
|     void Class::writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state) const {} |     void Class::writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state) const {} | ||||||
| 
 | 
 | ||||||
|     int Class::getBaseGold(const MWWorld::Ptr& ptr) const |     int Class::getBaseGold(const MWWorld::Ptr& ptr) const | ||||||
|     { |     { | ||||||
|  |  | ||||||
|  | @ -171,7 +171,7 @@ namespace MWWorld | ||||||
|             ///< Returns the remaining duration of the object, such as an equippable light
 |             ///< Returns the remaining duration of the object, such as an equippable light
 | ||||||
|             /// source. (default implementation: -1, i.e. infinite)
 |             /// source. (default implementation: -1, i.e. infinite)
 | ||||||
| 
 | 
 | ||||||
|             virtual std::string getScript (const Ptr& ptr) const; |             virtual std::string getScript (const ConstPtr& ptr) const; | ||||||
|             ///< Return name of the script attached to ptr (default implementation: return an empty
 |             ///< Return name of the script attached to ptr (default implementation: return an empty
 | ||||||
|             /// string).
 |             /// string).
 | ||||||
| 
 | 
 | ||||||
|  | @ -313,7 +313,7 @@ namespace MWWorld | ||||||
|                 const; |                 const; | ||||||
|             ///< Read additional state from \a state into \a ptr.
 |             ///< Read additional state from \a state into \a ptr.
 | ||||||
| 
 | 
 | ||||||
|             virtual void writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state) |             virtual void writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state) | ||||||
|                 const; |                 const; | ||||||
|             ///< Write additional state from \a ptr into \a state.
 |             ///< Write additional state from \a ptr into \a state.
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -94,7 +94,7 @@ void MWWorld::ContainerStore::storeState (const LiveCellRef<T>& ref, ESM::Object | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| template<typename T> | template<typename T> | ||||||
| void MWWorld::ContainerStore::storeStates (CellRefList<T>& collection, | void MWWorld::ContainerStore::storeStates (const CellRefList<T>& collection, | ||||||
|     ESM::InventoryState& inventory, int& index, bool equipable) const |     ESM::InventoryState& inventory, int& index, bool equipable) const | ||||||
| { | { | ||||||
|     for (typename CellRefList<T>::List::const_iterator iter (collection.mList.begin()); |     for (typename CellRefList<T>::List::const_iterator iter (collection.mList.begin()); | ||||||
|  | @ -707,7 +707,7 @@ MWWorld::Ptr MWWorld::ContainerStore::search (const std::string& id) | ||||||
|     return Ptr(); |     return Ptr(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void MWWorld::ContainerStore::writeState (ESM::InventoryState& state) | void MWWorld::ContainerStore::writeState (ESM::InventoryState& state) const | ||||||
| { | { | ||||||
|     state.mItems.clear(); |     state.mItems.clear(); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -86,7 +86,7 @@ namespace MWWorld | ||||||
|             void storeState (const LiveCellRef<T>& ref, ESM::ObjectState& state) const; |             void storeState (const LiveCellRef<T>& ref, ESM::ObjectState& state) const; | ||||||
| 
 | 
 | ||||||
|             template<typename T> |             template<typename T> | ||||||
|             void storeStates (CellRefList<T>& collection, |             void storeStates (const CellRefList<T>& collection, | ||||||
|                 ESM::InventoryState& inventory, int& index, |                 ESM::InventoryState& inventory, int& index, | ||||||
|                 bool equipable = false) const; |                 bool equipable = false) const; | ||||||
| 
 | 
 | ||||||
|  | @ -169,8 +169,7 @@ namespace MWWorld | ||||||
| 
 | 
 | ||||||
|             Ptr search (const std::string& id); |             Ptr search (const std::string& id); | ||||||
| 
 | 
 | ||||||
|             /// \todo make this method const once const-correct ContainerStoreIterators are available
 |             virtual void writeState (ESM::InventoryState& state) const; | ||||||
|             virtual void writeState (ESM::InventoryState& state); |  | ||||||
| 
 | 
 | ||||||
|             virtual void readState (const ESM::InventoryState& state); |             virtual void readState (const ESM::InventoryState& state); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -752,7 +752,7 @@ bool MWWorld::InventoryStore::isEquipped(const MWWorld::Ptr &item) | ||||||
|     return false; |     return false; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void MWWorld::InventoryStore::writeState(ESM::InventoryState &state) | void MWWorld::InventoryStore::writeState(ESM::InventoryState &state) const | ||||||
| { | { | ||||||
|     MWWorld::ContainerStore::writeState(state); |     MWWorld::ContainerStore::writeState(state); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -207,7 +207,7 @@ namespace MWWorld | ||||||
|             virtual void clear(); |             virtual void clear(); | ||||||
|             ///< Empty container.
 |             ///< Empty container.
 | ||||||
| 
 | 
 | ||||||
|             virtual void writeState (ESM::InventoryState& state); |             virtual void writeState (ESM::InventoryState& state) const; | ||||||
| 
 | 
 | ||||||
|             virtual void readState (const ESM::InventoryState& state); |             virtual void readState (const ESM::InventoryState& state); | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|  | @ -54,8 +54,7 @@ void MWWorld::LiveCellRefBase::saveImp (ESM::ObjectState& state) const | ||||||
| { | { | ||||||
|     mRef.writeState(state); |     mRef.writeState(state); | ||||||
| 
 | 
 | ||||||
|     /// \todo get rid of this cast once const-correct Ptr are available
 |     ConstPtr ptr (this); | ||||||
|     Ptr ptr (const_cast<LiveCellRefBase *> (this)); |  | ||||||
| 
 | 
 | ||||||
|     mData.write (state, mClass->getScript (ptr)); |     mData.write (state, mClass->getScript (ptr)); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -52,3 +52,25 @@ MWWorld::Ptr::operator const void *() | ||||||
| { | { | ||||||
|     return mRef; |     return mRef; | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | // -------------------------------------------------------------------------------
 | ||||||
|  | 
 | ||||||
|  | const std::string &MWWorld::ConstPtr::getTypeName() const | ||||||
|  | { | ||||||
|  |     if(mRef != 0) | ||||||
|  |         return mRef->mClass->getTypeName(); | ||||||
|  |     throw std::runtime_error("Can't get type name from an empty object."); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | const MWWorld::LiveCellRefBase *MWWorld::ConstPtr::getBase() const | ||||||
|  | { | ||||||
|  |     if (!mRef) | ||||||
|  |         throw std::runtime_error ("Can't access cell ref pointed to by null Ptr"); | ||||||
|  | 
 | ||||||
|  |     return mRef; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | MWWorld::ConstPtr::operator const void *() | ||||||
|  | { | ||||||
|  |     return mRef; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -85,6 +85,87 @@ namespace MWWorld | ||||||
|             ///< Return a 0-pointer, if Ptr is empty; return a non-0-pointer, if Ptr is not empty
 |             ///< Return a 0-pointer, if Ptr is empty; return a non-0-pointer, if Ptr is not empty
 | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|  |     /// \brief Pointer to a const LiveCellRef
 | ||||||
|  |     /// @note a Ptr can be implicitely converted to a ConstPtr, but you can not convert a ConstPtr to a Ptr.
 | ||||||
|  |     class ConstPtr | ||||||
|  |     { | ||||||
|  |     public: | ||||||
|  | 
 | ||||||
|  |         const MWWorld::LiveCellRefBase *mRef; | ||||||
|  |         const CellStore *mCell; | ||||||
|  |         const ContainerStore *mContainerStore; | ||||||
|  | 
 | ||||||
|  |     public: | ||||||
|  |         ConstPtr(const MWWorld::LiveCellRefBase *liveCellRef=0, const CellStore *cell=0) | ||||||
|  |           : mRef(liveCellRef), mCell(cell), mContainerStore(0) | ||||||
|  |         { | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         ConstPtr(const MWWorld::Ptr& ptr) | ||||||
|  |             : mRef(ptr.mRef), mCell(ptr.mCell), mContainerStore(ptr.mContainerStore) | ||||||
|  |         { | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         bool isEmpty() const | ||||||
|  |         { | ||||||
|  |             return mRef == 0; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         const std::string& getTypeName() const; | ||||||
|  | 
 | ||||||
|  |         const Class& getClass() const | ||||||
|  |         { | ||||||
|  |             if(mRef != 0) | ||||||
|  |                 return *(mRef->mClass); | ||||||
|  |             throw std::runtime_error("Cannot get class of an empty object"); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         template<typename T> | ||||||
|  |         const MWWorld::LiveCellRef<T> *get() const | ||||||
|  |         { | ||||||
|  |             const MWWorld::LiveCellRef<T> *ref = dynamic_cast<const MWWorld::LiveCellRef<T>*>(mRef); | ||||||
|  |             if(ref) return ref; | ||||||
|  | 
 | ||||||
|  |             std::stringstream str; | ||||||
|  |             str<< "Bad LiveCellRef cast to "<<typeid(T).name()<<" from "; | ||||||
|  |             if(mRef != 0) str<< getTypeName(); | ||||||
|  |             else str<< "an empty object"; | ||||||
|  | 
 | ||||||
|  |             throw std::runtime_error(str.str()); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         const MWWorld::LiveCellRefBase *getBase() const; | ||||||
|  | 
 | ||||||
|  |         const MWWorld::CellRef& getCellRef() const | ||||||
|  |         { | ||||||
|  |             assert(mRef); | ||||||
|  |             return mRef->mRef; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         const RefData& getRefData() const | ||||||
|  |         { | ||||||
|  |             assert(mRef); | ||||||
|  |             return mRef->mData; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         const CellStore *getCell() const | ||||||
|  |         { | ||||||
|  |             assert(mCell); | ||||||
|  |             return mCell; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         bool isInCell() const | ||||||
|  |         { | ||||||
|  |             return (mContainerStore == 0) && (mCell != 0); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         const ContainerStore *getContainerStore() const; | ||||||
|  |         ///< May return a 0-pointer, if reference is not in a container.
 | ||||||
|  | 
 | ||||||
|  |         operator const void *(); | ||||||
|  |         ///< Return a 0-pointer, if Ptr is empty; return a non-0-pointer, if Ptr is not empty
 | ||||||
|  |     }; | ||||||
|  | 
 | ||||||
|     inline bool operator== (const Ptr& left, const Ptr& right) |     inline bool operator== (const Ptr& left, const Ptr& right) | ||||||
|     { |     { | ||||||
|         return left.mRef==right.mRef; |         return left.mRef==right.mRef; | ||||||
|  |  | ||||||
|  | @ -205,6 +205,11 @@ namespace MWWorld | ||||||
|         return mCustomData; |         return mCustomData; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     const CustomData *RefData::getCustomData() const | ||||||
|  |     { | ||||||
|  |         return mCustomData; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     bool RefData::hasChanged() const |     bool RefData::hasChanged() const | ||||||
|     { |     { | ||||||
|         return mChanged; |         return mChanged; | ||||||
|  |  | ||||||
|  | @ -116,6 +116,8 @@ namespace MWWorld | ||||||
|             CustomData *getCustomData(); |             CustomData *getCustomData(); | ||||||
|             ///< May return a 0-pointer. The ownership of the return data object is not transferred.
 |             ///< May return a 0-pointer. The ownership of the return data object is not transferred.
 | ||||||
| 
 | 
 | ||||||
|  |             const CustomData *getCustomData() const; | ||||||
|  | 
 | ||||||
|             bool hasChanged() const; |             bool hasChanged() const; | ||||||
|             ///< Has this RefData changed since it was originally loaded?
 |             ///< Has this RefData changed since it was originally loaded?
 | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|  | @ -2805,7 +2805,7 @@ namespace MWWorld | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     MWWorld::Ptr World::getClosestMarker( const MWWorld::Ptr &ptr, const std::string &id ) |     MWWorld::ConstPtr World::getClosestMarker( const MWWorld::Ptr &ptr, const std::string &id ) | ||||||
|     { |     { | ||||||
|         if ( ptr.getCell()->isExterior() ) { |         if ( ptr.getCell()->isExterior() ) { | ||||||
|             return getClosestMarkerFromExteriorPosition(mPlayer->getLastKnownExteriorPosition(), id); |             return getClosestMarkerFromExteriorPosition(mPlayer->getLastKnownExteriorPosition(), id); | ||||||
|  | @ -2817,7 +2817,7 @@ namespace MWWorld | ||||||
|         std::set< std::string >checkedCells; |         std::set< std::string >checkedCells; | ||||||
|         std::set< std::string >currentCells; |         std::set< std::string >currentCells; | ||||||
|         std::set< std::string >nextCells; |         std::set< std::string >nextCells; | ||||||
|         MWWorld::Ptr closestMarker; |         MWWorld::ConstPtr closestMarker; | ||||||
| 
 | 
 | ||||||
|         nextCells.insert( ptr.getCell()->getCell()->mName ); |         nextCells.insert( ptr.getCell()->getCell()->mName ); | ||||||
|         while ( !nextCells.empty() ) { |         while ( !nextCells.empty() ) { | ||||||
|  | @ -2861,8 +2861,8 @@ namespace MWWorld | ||||||
|         return MWWorld::Ptr(); |         return MWWorld::Ptr(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     MWWorld::Ptr World::getClosestMarkerFromExteriorPosition( const osg::Vec3f& worldPos, const std::string &id ) { |     MWWorld::ConstPtr World::getClosestMarkerFromExteriorPosition( const osg::Vec3f& worldPos, const std::string &id ) { | ||||||
|         MWWorld::Ptr closestMarker; |         MWWorld::ConstPtr closestMarker; | ||||||
|         float closestDistance = std::numeric_limits<float>::max(); |         float closestDistance = std::numeric_limits<float>::max(); | ||||||
| 
 | 
 | ||||||
|         std::vector<MWWorld::Ptr> markers; |         std::vector<MWWorld::Ptr> markers; | ||||||
|  | @ -2887,7 +2887,7 @@ namespace MWWorld | ||||||
|     void World::teleportToClosestMarker (const MWWorld::Ptr& ptr, |     void World::teleportToClosestMarker (const MWWorld::Ptr& ptr, | ||||||
|                                           const std::string& id) |                                           const std::string& id) | ||||||
|     { |     { | ||||||
|         MWWorld::Ptr closestMarker = getClosestMarker( ptr, id ); |         MWWorld::ConstPtr closestMarker = getClosestMarker( ptr, id ); | ||||||
| 
 | 
 | ||||||
|         if ( closestMarker.isEmpty() ) |         if ( closestMarker.isEmpty() ) | ||||||
|         { |         { | ||||||
|  | @ -3047,13 +3047,13 @@ namespace MWWorld | ||||||
| 
 | 
 | ||||||
|     void World::confiscateStolenItems(const Ptr &ptr) |     void World::confiscateStolenItems(const Ptr &ptr) | ||||||
|     { |     { | ||||||
|         MWWorld::Ptr prisonMarker = getClosestMarker( ptr, "prisonmarker" ); |         MWWorld::ConstPtr prisonMarker = getClosestMarker( ptr, "prisonmarker" ); | ||||||
|         if ( prisonMarker.isEmpty() ) |         if ( prisonMarker.isEmpty() ) | ||||||
|         { |         { | ||||||
|             std::cerr << "Failed to confiscate items: no closest prison marker found." << std::endl; |             std::cerr << "Failed to confiscate items: no closest prison marker found." << std::endl; | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|         std::string prisonName = prisonMarker.mRef->mRef.getDestCell(); |         std::string prisonName = prisonMarker.getCellRef().getDestCell(); | ||||||
|         if ( prisonName.empty() ) |         if ( prisonName.empty() ) | ||||||
|         { |         { | ||||||
|             std::cerr << "Failed to confiscate items: prison marker not linked to prison interior" << std::endl; |             std::cerr << "Failed to confiscate items: prison marker not linked to prison interior" << std::endl; | ||||||
|  |  | ||||||
|  | @ -165,8 +165,8 @@ namespace MWWorld | ||||||
| 
 | 
 | ||||||
|             float feetToGameUnits(float feet); |             float feetToGameUnits(float feet); | ||||||
| 
 | 
 | ||||||
|             MWWorld::Ptr getClosestMarker( const MWWorld::Ptr &ptr, const std::string &id ); |             MWWorld::ConstPtr getClosestMarker( const MWWorld::Ptr &ptr, const std::string &id ); | ||||||
|             MWWorld::Ptr getClosestMarkerFromExteriorPosition( const osg::Vec3f& worldPos, const std::string &id ); |             MWWorld::ConstPtr getClosestMarkerFromExteriorPosition( const osg::Vec3f& worldPos, const std::string &id ); | ||||||
| 
 | 
 | ||||||
|         public: |         public: | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue