mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-07 21:36:41 +00:00
Address review comments
This commit is contained in:
parent
8d1e52ed51
commit
a88fcbffb0
5 changed files with 16 additions and 16 deletions
|
@ -17,12 +17,12 @@ namespace MWLua
|
||||||
class EngineEvents::Visitor
|
class EngineEvents::Visitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit Visitor(GlobalScripts* globalScripts)
|
explicit Visitor(GlobalScripts& globalScripts)
|
||||||
: mGlobalScripts(globalScripts)
|
: mGlobalScripts(globalScripts)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()(const OnNewGame&) const { mGlobalScripts->newGameStarted(); }
|
void operator()(const OnNewGame&) const { mGlobalScripts.newGameStarted(); }
|
||||||
|
|
||||||
void operator()(const OnActive& event) const
|
void operator()(const OnActive& event) const
|
||||||
{
|
{
|
||||||
|
@ -30,15 +30,15 @@ namespace MWLua
|
||||||
if (ptr.isEmpty())
|
if (ptr.isEmpty())
|
||||||
return;
|
return;
|
||||||
if (ptr.getCellRef().getRefId() == "player")
|
if (ptr.getCellRef().getRefId() == "player")
|
||||||
mGlobalScripts->playerAdded(GObject(ptr));
|
mGlobalScripts.playerAdded(GObject(ptr));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mGlobalScripts->objectActive(GObject(ptr));
|
mGlobalScripts.objectActive(GObject(ptr));
|
||||||
const MWWorld::Class& objClass = ptr.getClass();
|
const MWWorld::Class& objClass = ptr.getClass();
|
||||||
if (objClass.isActor())
|
if (objClass.isActor())
|
||||||
mGlobalScripts->actorActive(GObject(ptr));
|
mGlobalScripts.actorActive(GObject(ptr));
|
||||||
if (objClass.isItem(ptr))
|
if (objClass.isItem(ptr))
|
||||||
mGlobalScripts->itemActive(GObject(ptr));
|
mGlobalScripts.itemActive(GObject(ptr));
|
||||||
}
|
}
|
||||||
if (auto* scripts = getLocalScripts(ptr))
|
if (auto* scripts = getLocalScripts(ptr))
|
||||||
scripts->setActive(true);
|
scripts->setActive(true);
|
||||||
|
@ -89,7 +89,7 @@ namespace MWLua
|
||||||
|
|
||||||
LocalScripts* getLocalScripts(const ESM::RefNum& id) const { return getLocalScripts(getPtr(id)); }
|
LocalScripts* getLocalScripts(const ESM::RefNum& id) const { return getLocalScripts(getPtr(id)); }
|
||||||
|
|
||||||
GlobalScripts* mGlobalScripts;
|
GlobalScripts& mGlobalScripts;
|
||||||
bool mLuaDebug = Settings::Manager::getBool("lua debug", "Lua");
|
bool mLuaDebug = Settings::Manager::getBool("lua debug", "Lua");
|
||||||
MWWorld::WorldModel* mWorldModel = MWBase::Environment::get().getWorldModel();
|
MWWorld::WorldModel* mWorldModel = MWBase::Environment::get().getWorldModel();
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace MWLua
|
||||||
class EngineEvents
|
class EngineEvents
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit EngineEvents(GlobalScripts* globalScripts)
|
explicit EngineEvents(GlobalScripts& globalScripts)
|
||||||
: mGlobalScripts(globalScripts)
|
: mGlobalScripts(globalScripts)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ namespace MWLua
|
||||||
private:
|
private:
|
||||||
class Visitor;
|
class Visitor;
|
||||||
|
|
||||||
GlobalScripts* mGlobalScripts;
|
GlobalScripts& mGlobalScripts;
|
||||||
std::vector<Event> mQueue;
|
std::vector<Event> mQueue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -35,10 +35,10 @@ namespace MWLua
|
||||||
|
|
||||||
void LuaEvents::callEventHandlers()
|
void LuaEvents::callEventHandlers()
|
||||||
{
|
{
|
||||||
for (Global& e : mGlobalEventBatch)
|
for (const Global& e : mGlobalEventBatch)
|
||||||
mGlobalScripts->receiveEvent(e.mEventName, e.mEventData);
|
mGlobalScripts.receiveEvent(e.mEventName, e.mEventData);
|
||||||
mGlobalEventBatch.clear();
|
mGlobalEventBatch.clear();
|
||||||
for (Local& e : mLocalEventBatch)
|
for (const Local& e : mLocalEventBatch)
|
||||||
{
|
{
|
||||||
MWWorld::Ptr ptr = MWBase::Environment::get().getWorldModel()->getPtr(e.mDest);
|
MWWorld::Ptr ptr = MWBase::Environment::get().getWorldModel()->getPtr(e.mDest);
|
||||||
LocalScripts* scripts = ptr.isEmpty() ? nullptr : ptr.getRefData().getLuaScripts();
|
LocalScripts* scripts = ptr.isEmpty() ? nullptr : ptr.getRefData().getLuaScripts();
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace MWLua
|
||||||
class LuaEvents
|
class LuaEvents
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit LuaEvents(GlobalScripts* globalScripts)
|
explicit LuaEvents(GlobalScripts& globalScripts)
|
||||||
: mGlobalScripts(globalScripts)
|
: mGlobalScripts(globalScripts)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ namespace MWLua
|
||||||
void save(ESM::ESMWriter& esm) const;
|
void save(ESM::ESMWriter& esm) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GlobalScripts* mGlobalScripts;
|
GlobalScripts& mGlobalScripts;
|
||||||
std::vector<Global> mNewGlobalEventBatch;
|
std::vector<Global> mNewGlobalEventBatch;
|
||||||
std::vector<Local> mNewLocalEventBatch;
|
std::vector<Local> mNewLocalEventBatch;
|
||||||
std::vector<Global> mGlobalEventBatch;
|
std::vector<Global> mGlobalEventBatch;
|
||||||
|
|
|
@ -172,8 +172,8 @@ namespace MWLua
|
||||||
|
|
||||||
MWWorld::Ptr mPlayer;
|
MWWorld::Ptr mPlayer;
|
||||||
|
|
||||||
LuaEvents mLuaEvents{ &mGlobalScripts };
|
LuaEvents mLuaEvents{ mGlobalScripts };
|
||||||
EngineEvents mEngineEvents{ &mGlobalScripts };
|
EngineEvents mEngineEvents{ mGlobalScripts };
|
||||||
std::vector<MWBase::LuaManager::InputEvent> mInputEvents;
|
std::vector<MWBase::LuaManager::InputEvent> mInputEvents;
|
||||||
|
|
||||||
std::unique_ptr<LuaUtil::UserdataSerializer> mGlobalSerializer;
|
std::unique_ptr<LuaUtil::UserdataSerializer> mGlobalSerializer;
|
||||||
|
|
Loading…
Reference in a new issue