Commit graph

93 commits

Author SHA1 Message Date
Edoardo Lolletti
481031ba9e Add extra LUA_NAMESPACE 2025-07-05 19:50:36 +02:00
Edoardo Lolletti
d0f57fb823 Debug.AddCard Check if the passed location is valid
Fixes crash caused by passing a sequence value too big for field locations
2025-06-28 18:10:02 +02:00
Edoardo Lolletti
b5818e2ed6 Minor update to Debug.PreAddCounter 2025-02-25 18:23:41 +01:00
Edoardo Lolletti
a388095e1f Wrap luaL calls so that the lua stack has always at least 5 elements
Functions from the auxiliary library, assume the stack has always at least 5 empty slots, add macro ensure_luaL_stack to wrap every such call so that the stack is checked for enough free space beforehand. This will make mandatory to use the latest version of visual studio 2017 as minimum for windows (it was already being required for c++17 support regardless), as it needs the conformant c++ preprocessor option to be used.
2024-04-13 10:36:47 +02:00
Edoardo Lolletti
dd32bac788 Made scriptlib::check_param templated
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.
2024-03-01 17:57:41 +01:00
Edoardo Lolletti
ff41aec90a Update header inclusion 2024-01-05 13:03:46 +01:00
Edoardo Lolletti
8b4bd4ac53 Update field functions to properly take bool and not uint8_t 2024-01-03 14:29:48 +01:00
Edoardo Lolletti
da45f91460 Update copyright for 2024 2024-01-03 01:21:08 +01:00
Edoardo Lolletti
6dc321de75 Make LuaParamType an enum class 2023-12-08 19:55:50 +01:00
Edoardo Lolletti
434b775193 C++17 constructs 2023-11-26 17:47:46 +01:00
Edoardo Lolletti
20fbf2d87e LUA_FUNCTION: directly pass pduel in the function scope
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
2023-11-25 11:15:21 +01:00
Edoardo Lolletti
420d5b6107 LUA_FUNCTION: directly pass "self" parameter referring to the object
Most of the library functions are used as "class member functions" where the first parameter is always the corresponding lua object, update the LUA_FUNCTION macro so that the functions already have a "self" parameter corresponding to the already parsed lua object.
Added a new LUA_STATIC_FUNCTION macro for functions that are to be called without an associated object
2023-11-21 11:56:23 +01:00
Edoardo Lolletti
e73fb449a8 Silence downcast warnings 2023-02-07 16:43:27 +01:00
Edoardo Lolletti
959577810f Fix Debug.AddCard not setting the pzone state properly
Fixes regression introduced in 99361da960
2022-12-08 10:50:29 +01:00
Edoardo Lolletti
29a7a057f1 Minor update to the way the summon info are stored
Decouple the summon location from the summon type, also keep track of the sequence and if the card was in a pzone, this allows to use symbolic locations in Card.IsSummonLocation as wel
2022-10-30 11:08:18 +01:00
Edoardo Lolletti
99361da960 Fix some places where the offseted sequences weren't being handled 2022-10-28 20:23:23 +02:00
Edoardo Lolletti
b6ba9febc6 Fix field effects being enabled for facedown field spells played with Debug.AddCard 2022-10-27 22:13:01 +02:00
Edoardo Lolletti
32606c2c91 Update Debug.Message
No longer call the lua funciton ``tostring`` to format the string but use the proper c api function luaL_tolstring, also support passing multiple values, in which case they'll be printed as if multiple Debug.Message calls were made
2022-10-24 18:16:28 +02:00
Edoardo Lolletti
a64cadf247 Add a __tostring method to card objects
Due to the way each card object is designed, the __tostring method has to be put in each cXXXXXX table, and cannot be put in the Card table as lua will do a rawget on the metatable to get the metamethods. Use a "wrapper" function as default tostring method to handle when that method is called directly from the metatable itself and not from a card object, that will load a defined Debug.CardToString function if present, otherwise emulates the same tostring behaviour lua uses
2022-10-20 19:07:56 +02:00
Edoardo Lolletti
db4195592e Fix failed assertion if Debug.Message is called with no arguments 2022-05-31 16:31:23 +02:00
Edoardo Lolletti
d97b8770c8 Yield in some more Duel and Debug function
Yield in functions that actively change the game/board state such as the "Shuffle" functions, TagSwap and Debug.ReloadFieldEnd.
2022-05-16 19:57:17 +02:00
Edoardo Lolletti
3ba3d949a4 Add static asserts to ensure constexpr evaluation 2022-05-15 16:02:35 +02:00
Edoardo Lolletti
bd3b33c763 Update Debug library to use new declaration 2022-05-15 16:02:35 +02:00
Edoardo Lolletti
1278081fc6 Minor formatting updates 2022-03-04 23:53:28 +01:00
Edoardo Lolletti
6fe72bab09 Remove all NULL usage
Use nullptr
2021-12-13 14:07:51 +01:00
Edoardo Lolletti
c7d2accb8c Remove scriptlib class
Make all the script functions scoped to their translation units, put the general functions under scriptlib namespace instead
2021-10-13 17:29:29 +02:00
Edoardo Lolletti
12636649e3 Cleanup libdebug.cpp 2021-10-12 22:59:25 +02:00
Edoardo Lolletti
9b272b35d6 Update logic for pzone index handling
Abstract the logic for pzone index checking a bit more and allow the possibility in future to individually toggle the placing of the zones on a per player basis
2021-09-28 11:55:44 +02:00
Edoardo Lolletti
8fd5b97d04 Completely remove custom integer type typedefs
Directly use the standard's
2021-09-04 22:04:14 +02:00
edo9300
6ec6a6cc06 Improved callback calls from duel class, replace sprintf interpreter function with "format", usign a buffer internal to the interpreter class
handle_message and read_script are now wrappers on top of the callbacks, will pass the payload and other needed parameters accordingly
2021-01-07 13:39:12 +01:00
edo9300
639a61fac7 Update lua functions related to strings
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.
2020-11-06 22:40:01 +01:00
edo9300
d98ab684d7 Always use lua_get<duel*>() in library functions that have to access it 2020-10-30 17:05:28 +01:00
edo9300
64f86fa6ae Add getters for bool/ints with default parameters, treat failed calls with no default params as errors 2020-07-23 23:50:09 +02:00
edo9300
f137ca6407 Function signatures formatting 2020-07-21 19:15:19 +02:00
edo9300
24141e6fed Libdebug 2020-07-21 15:58:11 +02:00
edo9300
c1c500e060 remove card2value, group2value, effect2value, function2value
Replaced them with generic "pushobject"
2020-07-20 22:05:04 +02:00
edo9300
681e401c9e Use new lua getters in effect, debug and group classes 2020-07-20 19:44:59 +02:00
edo9300
8a073daa1d Add new function for lua parameters getting 2020-07-12 14:57:26 +02:00
edo9300
69398817ad Remove unused duel flags 2020-05-29 15:42:12 +02:00
edo9300
1aaa78ec81 Always force non pendulum monsters in the extra deck to facedown defense 2020-05-12 20:26:07 +02:00
edo9300
4f3d4cf423 Revert "Revert "minor refactor of xyz overlay""
This reverts commit 8ba4ec24ee.
2020-04-12 13:11:54 +02:00
edo9300
8ba4ec24ee Revert "minor refactor of xyz overlay"
This reverts commit b8dbc0e8bf.
2020-04-12 12:54:03 +02:00
DailyShana
b8dbc0e8bf minor refactor of xyz overlay 2020-04-12 12:09:27 +02:00
edo9300
735526d96e Debug.AddCard, properly add card as overlayed material even for cards in spell/trap zone, updated MSG_RELOAD_FIELD accordingly 2020-01-16 22:46:17 +01:00
edo9300
27a99eb8e8 Added mr5 parameter support in on reload_field_begin 2020-01-09 00:03:55 +01:00
DailyShana
50f494de8a Debug.AddCard: set position of card in extra deck
if the position is not set
2020-01-08 22:34:55 +01:00
edo9300
117386528d Added Debug.PrintStacktrace and print backtrace on internal errors 2020-01-06 19:01:59 +01:00
edo9300
a34e847c1f Properly use lua_tointeger 2019-11-22 00:08:02 +01:00
kevinlul
4b45bb42c3 Use OCG_LogTypes enum, refix sprintf warnings 2019-09-29 13:41:45 -04:00
edo9300
4791166edb Send correct log type to callback function 2019-09-29 19:29:17 +02:00