Commit graph

108 commits

Author SHA1 Message Date
Edoardo Lolletti
a30e6b75a9 Make effect's category 64 bits 2026-01-15 20:22:30 +01:00
Edoardo Lolletti
fa9bea8f37 use lua_rawgeti to get table parameters in Effect,SetCountLimit
Don't rely on lua_next to return elements in order
2025-11-16 16:18:58 +01:00
Edoardo Lolletti
481031ba9e Add extra LUA_NAMESPACE 2025-07-05 19:50:36 +02:00
Edoardo Lolletti
b0fd826aa6 Use define for LUA_CLASS
To simplify some changes to be committed
2025-07-05 15:03:10 +02:00
Edoardo Lolletti
a184f67c1c Use pushinteger instead of pushvalue in Effect:SetValue's closure
Simple operations with less possible future issues caused by raw lua value indexing
2025-02-25 23:00:20 +01:00
Edoardo Lolletti
8e6eadb226 Add Effect.RestoreCountLimit 2024-05-19 14:23:57 +02: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
16add063f6 Remove check_param_count where redoundant
LUA_FUNCTIONs don't really need to check the amount of parameters to be at least 1, as that's implicitly checked by the mandatory first parameter being the lua_object itself
2024-02-25 15:55:53 +01:00
Edoardo Lolletti
ff41aec90a Update header inclusion 2024-01-05 13:03:46 +01:00
Edoardo Lolletti
da45f91460 Update copyright for 2024 2024-01-03 01:21:08 +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
d579a50aa0 Add handling in Effect.SetValue for int64 values
If the value does not fit an int32, use a closure to save that value so that it can be stored as a function in the 32 bit "value" field of the effect
2023-11-21 21:36:05 +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
70f419426c Don't push directly the result of bitwise operations with lua_pushboolean
Explicitly check for !=0 to avoid possible future oversights caused by the integers being changed becoming 64 bit
2023-08-12 10:19:31 +02:00
Edoardo Lolletti
97b31cb721 Address some warnings 2023-08-12 10:19:31 +02:00
Naim
dee679ca52
Add Effect.GetRange (#138)
Add Effect.GetRange
2023-05-14 01:39:05 +02:00
Edoardo Lolletti
85bec80d87 Add EFFECT_COUNT_CODE_CHAIN (import https://github.com/Fluorohydride/ygopro-core/pull/485) 2023-04-02 16:52:13 +02:00
Edoardo Lolletti
4eff4d1325 Add some extra checks to Effect.SetCountLimit
Error out on invalid usages rather than silently accepting them
2023-04-02 16:41:12 +02:00
Edoardo Lolletti
e73fb449a8 Silence downcast warnings 2023-02-07 16:43:27 +01:00
Naim
1a59429b21 Add Effect.GetHintTiming (#132) 2022-12-17 15:24:21 +01:00
Edoardo Lolletti
747bbbf971 Attempt to fix issue where effects with range LOCATION_EMZONE would break if the card was moved from the emzone to the mmzone 2022-12-08 10:43:24 +01:00
Edoardo Lolletti
151a5b7f71
Add support for table arguments in function already accepting a variable number of parameters (#131)
Also update the IsSetCard function family to work with a table as parameter as well
2022-10-26 18:13:11 +02:00
Edoardo Lolletti
e3bdbad9bf Minor update to Effect.GetLabel
Check the stack before pushing
2022-10-25 15:41:11 +02:00
Edoardo Lolletti
2ce69cbf50 Update some instances where the usage of lua_gettop was unoptimal or redoundant
In loops don't reevaluate it each iteration, in some functions already checking the value before entering a specific codepath don't repeat the same check
2022-10-19 15:04:27 +02:00
Edoardo Lolletti
409b48524c Use effect::get_owner() in Effect.GetOwner
Account for EFFECT_TYPE_XMATERIAL
2022-08-15 11:26:12 +02:00
Edoardo Lolletti
f255e1c883 Add helper lua_error function
Add this function marked as noreturn to avoid putting unreachable() after every luaL_error call
2022-06-23 11:47:00 +02:00
Edoardo Lolletti
b6550fd9d3 Use teh new function to retrieve function indices in lua apis
Use the new function that return "0" if the object is not a function so that the functions can automatically take advantage of the change in check_matching that skips the second type check each function call.
2022-06-11 12:59:38 +02:00
Edoardo Lolletti
3ba3d949a4 Add static asserts to ensure constexpr evaluation 2022-05-15 16:02:35 +02:00
Edoardo Lolletti
a3f1bcb10c Update Effect library to use new declaration 2022-05-15 16:02:35 +02:00
Edoardo Lolletti
8e6ce5a479 Use lua_Integer for effect label's type 2022-04-25 10:33:01 +02:00
Edoardo Lolletti
ce7e7eee06 Revert "Mark for deletion groups set as labels in an effect when it's destroyed"
This reverts commit a85826a7d7.
2022-03-25 18:17:01 +01:00
Edoardo Lolletti
a85826a7d7 Mark for deletion groups set as labels in an effect when it's destroyed 2022-03-24 18:19:53 +01:00
Edoardo Lolletti
16ab615b83 Add Effect.GetTargetRange 2022-03-12 16:42:45 +01:00
Edoardo Lolletti
4e824b0a19 Silence Wmissing-field-initializers in duel::clear
False positive
2022-03-05 14:07:59 +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
8fd5b97d04 Completely remove custom integer type typedefs
Directly use the standard's
2021-09-04 22:04:14 +02:00
Edoardo Lolletti
a7c90b43c0 Fix effect::count_hopt_index not being default initialized 2021-09-03 18:58:19 +02:00
Edoardo Lolletti
67068a5052 Add hopt index for effects' count limit
Update Effect.SetCountLimit to allow passing a table containing id and hopt index as 3rd parameter, used for when cards have multiple hopt effects that can be acivated.
Also updated Effect.GetCountLimit to reflect this change
2021-09-02 19:28:10 +02:00
Edoardo Lolletti
b9d11fa544 Always take a reference to effect label objects
It was possible for an effect's label object to be collected, and then its reference assigned to another variable, thus making the reference inexact
2021-06-26 15:24:35 +02:00
Edoardo Lolletti
d688c6a9bc Minor cleanup in effect_get_label_object
Simplify the branches
2021-04-04 00:01:24 +02:00
Edoardo Lolletti
f446a4a6c0 Set label_object to 0 immediately before trying to parse the arguments
Prevents it from being left unreferenced but still set after a throw because of wrong argument type.
2021-04-04 00:00:46 +02:00
Edoardo Lolletti
4c12674b92 Remove backward compatibility support for Effect.SetCountLimit 2021-01-18 15:12:26 +01:00
edo9300
bb01859d6b Add handling for onjects exposed to the lua api and still possibly referenced inside it
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.
2021-01-03 23:26:33 +01:00
edo9300
321c5f163c replace lua_isnil with lua_isnoneornil 2020-12-26 00:31:31 +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
c8a0483dbb typo 2020-10-17 21:06:52 +02:00
edo9300
f961b5efb4 Allow lua tables to be set as label objects 2020-10-17 20:17:09 +02:00
edo9300
2f8391b916 Improved 20c6041f58 2020-09-05 20:35:13 +02:00