No longer manage a Group's lifetime explicitly in native code, but instead leverage Lua's garbage collector to handle it's lifetime.
In this change, Groups will be stored internally in the core inside a weak table, so that they will still be reference-able when needed, but if no reference were to exist in Lua code, they will be subject to garbage collection.
Whenever a Group is used by native code, its wrapped by a owned_lua template class, this is akin to std::shared_ptr--It reference counts the usages of that group internally in the core, including managing it in the Lua registry index when in use, so that it won't be collected.
With this approach, the exponential memory usage growth caused by long running procedures due to the creation hundredths of thousands of groups per iteration, is mitigated, since the temporary groups will be reaped more frequently, as opposed to the old approach of them being cleared only after the topmost Lua function had finished executing.
For now a single GC step is triggered whenever the total number of groups is more than 2048--an arbitrary value that seems to work well enough, but which can be changed/optimized after proper profiling.
A major upgrade with this approach is the removal of the concept of Groups "kept alive" and having to "explicitly delete" them to make them outlive a Lua function execution, since they will now follow Lua's variables lifetime properly.
Made the function more constexpr friendly, removing the need to perform the switch at runtime.
Also now when a parameter doesn't match the required type, its type will also be printed in the error as well.
Update lua functions to already have the pduel parameter passed inside them, thus not needing to manually retrieve them in the functions.
Add also a yieldk macro that does the same thing but for the yield continuation function, removing the redoundancies
Update lua functions calling functions, moved most of their common code in inline helper functions, simplify some code flow logic, use raw string literals when formatting strings
Currently the core just deallocated the internal object without doing nothing lua side, thus allowing the api to access invalid memory locations previously pointed by referenced objects. Added dummy `deleted` object that will take the place of any deleted lua/c object, raising errors when the api tries to read a lua_obj from the lua stack, so that the address pointed by the lua object will always be valid.
Also fixed possible crash when the label object passed to an EFFECT_TYPE_GRANT effect wasn't a valid effect.
Remove global duel::strbuffer, this was a leftover from the old message handling, directly pass the string from lua to the callback function, and use local buffers when formatting is needed.
Have base class lua_obj also register the type of the parameter, so that we don't have to rely on calling lua functions, but the value of teh struct can be directly checked