diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 0b750b1c3f..30596a209f 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -411,7 +411,7 @@ namespace MWWorld const std::string& master, const boost::filesystem::path& resDir, bool newGame, Environment& environment, const std::string& encoding) : mSkyManager (0), mScene (renderer,physEng), mPlayer (0), mCurrentCell (0), mGlobalVariables (0), - mSky (false), mCellChanged (false), mEnvironment (environment) + mSky (false), mCellChanged (false), mEnvironment (environment), mNextDynamicRecord (0) { mPhysEngine = physEng; @@ -871,4 +871,36 @@ namespace MWWorld { return mScene.toggleRenderMode (mode); } + + std::pair World::createRecord (const ESM::Potion& record) + { + /// \todo Rewrite the ESMStore so that a dynamic 2nd ESMStore can be attached to it. + /// This function should then insert the record into the 2nd store (the code for this + /// should also be moved to the ESMStore class). It might be a good idea to review + /// the STL-container usage of the ESMStore before the rewrite. + + std::ostringstream stream; + stream << "$dyamic" << mNextDynamicRecord++; + + const ESM::Potion *created = + &mStore.potions.list.insert (std::make_pair (stream.str(), record)).first->second; + + mStore.all.insert (std::make_pair (stream.str(), ESM::REC_ALCH)); + + return std::make_pair (stream.str(), created); + } + + std::pair World::createRecord (const ESM::Class& record) + { + /// \todo See function above. + std::ostringstream stream; + stream << "$dyamic" << mNextDynamicRecord++; + + const ESM::Class *created = + &mStore.classes.list.insert (std::make_pair (stream.str(), record)).first->second; + + mStore.all.insert (std::make_pair (stream.str(), ESM::REC_CLAS)); + + return std::make_pair (stream.str(), created); + } } diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index 188e5dec57..cccd8816df 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -79,6 +79,7 @@ namespace MWWorld bool mSky; bool mCellChanged; Environment& mEnvironment; + int mNextDynamicRecord; OEngine::Physic::PhysicEngine* mPhysEngine; @@ -202,6 +203,14 @@ namespace MWWorld bool toggleRenderMode (RenderMode mode); ///< Toggle a render mode. ///< \return Resulting mode + + std::pair createRecord (const ESM::Potion& record); + ///< Create a new recrod (of type potion) in the ESM store. + /// \return ID, pointer to created record + + std::pair createRecord (const ESM::Class& record); + ///< Create a new recrod (of type class) in the ESM store. + /// \return ID, pointer to created record }; }