MCPcopy Create free account
hub / github.com/cuberite/cuberite / AddHookRef

Method AddHookRef

src/Bindings/PluginLua.cpp:1563–1579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1561
1562
1563bool cPluginLua::AddHookRef(int a_HookType, int a_FnRefIdx)
1564{
1565 ASSERT(m_CriticalSection.IsLockedByCurrentThread()); // It probably has to be, how else would we have a LuaState?
1566
1567 // Check if the function reference is valid:
1568 cLuaState::cRef * Ref = new cLuaState::cRef(m_LuaState, a_FnRefIdx);
1569 if ((Ref == NULL) || !Ref->IsValid())
1570 {
1571 LOGWARNING("Plugin %s tried to add a hook %d with bad handler function.", GetName().c_str(), a_HookType);
1572 m_LuaState.LogStackTrace();
1573 delete Ref;
1574 return false;
1575 }
1576
1577 m_HookMap[a_HookType].push_back(Ref);
1578 return true;
1579}
1580
1581
1582

Calls 4

c_strMethod · 0.80
LogStackTraceMethod · 0.80
IsValidMethod · 0.45

Tested by

no test coverage detected