MCPcopy Create free account
hub / github.com/The-Powder-Toy/The-Powder-Toy / RemoveEventHandler

Method RemoveEventHandler

src/lua/LuaScriptInterface.cpp:467–493  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

465}
466
467void LuaScriptInterface::RemoveEventHandler(int eventType, int stackIndex)
468{
469 auto &list = gameControllerEventHandlers[eventType];
470 auto it = list.begin();
471 auto end = list.end();
472 lua_pushvalue(L, stackIndex);
473 while (it != end)
474 {
475 it->Push(L);
476 auto equal = lua_equal(L, -1, -2);
477 lua_pop(L, 1);
478 if (equal)
479 {
480 for (auto currentEventHandlerIt : currentEventHandlerIts)
481 {
482 if (*currentEventHandlerIt == it)
483 {
484 ++*currentEventHandlerIt;
485 }
486 }
487 list.erase(it);
488 break;
489 }
490 ++it;
491 }
492 lua_pop(L, 1);
493}
494
495template<size_t Index>
496std::enable_if_t<Index != std::variant_size_v<GameControllerEvent>, bool> HaveSimGraphicsEventHandlersHelper(const auto &gameControllerEventHandlers)

Callers 2

HandleEventMethod · 0.80
unregisterFunction · 0.80

Calls 3

PushMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected