| 1561 | |
| 1562 | |
| 1563 | bool 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 |
no test coverage detected