It's 12'000 lines of code if you want to check all events as opposed to not checking anything.KUDr wrote: βMon Nov 18, 2019 3:27 pmI would happily do it as a volunteer. Having some experience with C++ (25+ years) and with C++ templates incl. type lists (15+ years) I would like to at least try it. Assuming that you already have validators (i.e. functions) for all types involved in event handlers, it looks to me like one validator wrapper class for each type coming from LUA, one template class that can accept a list of these validator wrappers as template parameter and finally 144 different template instances (one for each event type). I would see it as ~3k lines of code + documentation depending on how many things (and how easily) I would be able to reuse. Ideally, I would not write a single validation piece of code and only reuse what you already have so that the same pieces of code are not spread on multiple places.Rseding91 wrote: βTue Nov 12, 2019 11:18 am I was thinking about what it would take to check everything passed through rase_event and it's just not a task that I think any sane human would want to sign up for. There are currently 144 events. The checks for all of them on the C++ side is around 3000 lines of code and that's not counting all of the functions they call themselves. The Lua version is typically 4 times larger due to all the mechanics of interacting with Lua data on the C++ side.
That's (at a guess) around 12'000 lines of code that someone would have to write all just to handle the rotten-eggs case of mods doing things wrong.
That doesn't make sense to me to do.
If on the other hand you write a "event_X" LUA binding for every event it's still 12'000 lines of code for all the checks. Plus 144 lua bindings adding another 1'000 lines of code.
Now compare that to keeping the existing event function and doing a switch/case. That's still 12'000 lines of code for all the checks plus 500 lines of code for the switch/case. And that's what I was talking about. Those +1'000 lines extra for lua bindings vs. 500 lines for switch/case. I would think adding checks to the existing one function should be simpler than adding 144 new functions with individual checks.
And all of that assumes you allow all events to be raised. Any event you don't allow reduces both the 12'000 lines of code to check, lua binding and the switch/case.