1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 05:19:55 +00:00
openmw-tes3mp/apps/openmw/mwworld/localscripts.hpp
scrawl cc3563359e Refactor local script iteration (Fixes #2806, Fixes #3108)
This should be much safer. Don't use recursion. Don't fail if mIgnore happens to be in the list twice. Don't rely on preconditions / assertions.
2016-02-03 16:16:20 +01:00

57 lines
1.6 KiB
C++

#ifndef GAME_MWWORLD_LOCALSCRIPTS_H
#define GAME_MWWORLD_LOCALSCRIPTS_H
#include <list>
#include <string>
#include "ptr.hpp"
namespace MWWorld
{
class ESMStore;
class CellStore;
class RefData;
/// \brief List of active local scripts
class LocalScripts
{
std::list<std::pair<std::string, Ptr> > mScripts;
std::list<std::pair<std::string, Ptr> >::iterator mIter;
MWWorld::ConstPtr mIgnore;
const MWWorld::ESMStore& mStore;
public:
LocalScripts (const MWWorld::ESMStore& store);
void setIgnore (const ConstPtr& ptr);
///< Mark a single reference for ignoring during iteration over local scripts (will revoke
/// previous ignores).
void startIteration();
///< Set the iterator to the begin of the script list.
bool getNext(std::pair<std::string, Ptr>& script);
///< Get next local script
/// @return Did we get a script?
void add (const std::string& scriptName, const Ptr& ptr);
///< Add script to collection of active local scripts.
void addCell (CellStore *cell);
///< Add all local scripts in a cell.
void clear();
///< Clear active local scripts collection.
void clearCell (CellStore *cell);
///< Remove all scripts belonging to \a cell.
void remove (RefData *ref);
void remove (const Ptr& ptr);
///< Remove script for given reference (ignored if reference does not have a script listed).
};
}
#endif