Commit graph

541 commits

Author SHA1 Message Date
Edoardo Lolletti
6e5398f563 Remove remnants of explicit group lifetime management
Rely entirely on lua, don't use `deleted` lua object to mark groups as deleted, fixes crashes under linux
2025-05-30 23:09:25 +02:00
Edoardo Lolletti
b01f23bfa6 Make group::is_readonly a bool
It is no longer used as multiple values "boolean" to indicate a group not to be collected
2025-05-30 23:09:23 +02:00
Edoardo Lolletti
50a2b9ba22 Add initial draft of lua managed group lifetime 2025-05-30 23:09:22 +02:00
Edoardo Lolletti
0b31b9b56d Add Duel.GetReasonPlayer and GetReasonEffect 2025-05-29 22:27:08 +02:00
Edoardo Lolletti
0d1e79a232 Make Duel.HintSelection default to true for the selection parameter 2025-04-13 15:07:49 +02:00
Edoardo Lolletti
7d31fdaade Make return values of Duel.GetChainInfo and Card.GetFlagEffectLabel actually int 2025-02-24 20:51:49 +01:00
Edoardo Lolletti
76ac85d3c0 Update copyright year on changed files and LICENSE 2025-02-23 13:56:35 +01:00
Edoardo Lolletti
8ada943825 Duel.HintSelection: Fix malformed message generation if nil was passed 2025-02-10 20:51:38 +01:00
Edoardo Lolletti
6fb126e385 Make Duel.EnableGlobalFlag noop
Global flags are automatically enabled when needed now
2024-11-04 22:42:59 +01:00
Edoardo Lolletti
4e56e5b677 Automatically register GLOBALFLAG_DECK_REVERSE_CHECK 2024-11-04 22:36:54 +01:00
Edoardo Lolletti
d7d440661e Explicitly check for parameter in Duel.LoadScript to be a string
Don't allow implicit conversions
2024-09-21 10:36:53 +02:00
Edoardo Lolletti
99b1a5b480 Fix wrong check in Duel.ChainAttack 2024-07-11 20:09:44 +02:00
Edoardo Lolletti
04f75a8da7 Fix crash when Duel.ChainAttack was called with no attacker 2024-05-30 12:20:55 +02:00
Edoardo Lolletti
b91dd7f752 Assert various warnings when compiling x64 with msvc 2024-04-15 22:39:25 +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
fffe496f50 Fix some errors introduced from previous commits 2024-04-01 00:07:27 +02:00
Edoardo Lolletti
0366e0088a Remove no longer needed (card*)nullptr in raise_event
There's no function ambiguity anymore
2024-03-08 11:12:46 +01:00
Edoardo Lolletti
ffe3ba695b Make field::raise_event take card_set by value 2024-03-08 11:03:06 +01:00
Edoardo Lolletti
c33b14ed04 replace lua_get with check_param 2024-03-07 16:36:12 +01: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
acaa99beb9 Use clang-tidy to update instances where 0 was used instead of nullptr 2024-01-13 16:30:50 +01:00
Edoardo Lolletti
e97a1c2f94
Restructure the processor handling to use a variant object (#149)
Rewrite the whole ``process`` function of the processor to use instead tag dispatching on variant objects.
Each single processor message got rewritten as a struct, inheriting from a base templated Process struct, containing only the required data for that process, rather than using the generic structure that ended up needing to spam bitwise operations to pack as many arguments in a byte as possible. This makes things easier to follow and streamlines the addition of new processes:
 - Define its struct with the parameters it expects by also providing a constructor
   - If the process requires an answer, inherit it from ``Process<true>``, if it requires no answer, inherit it from ``Process<false>``
 - Add such struct to the ``processors`` variant type
 - Declare and implement its corresponding ``bool process(Processors::NewProcess& arg);`` function
2024-01-08 20:46:41 +01:00
Edoardo Lolletti
6d83314fcf Use lua_iterate_table_or_stack instead of manually checking for table where needed 2024-01-06 21:52:34 +01:00
Edoardo Lolletti
9790b552a0 Address various warnings raised by clang's -Weverything
They were mostly extra breaks/extra semicolons
2024-01-05 15:50:25 +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
48a4ecf0b4 Fix possible crash in IsPlayerCanDiscardDeckAsCost with count of 0
If 0 was passed as count, and the checked player had no cards in his deck, and a EFFECT_TO_GRAVE_REDIRECT was applied, the core would've crashed
2023-12-21 21:58:07 +01:00
Naim
a2a979a00e
Added more chain info options (#153)
Added new flags for Duel.GetChainInfo:
TRIGGERING_STATUS: the status of the card
TRIGGERING_SUMMON_LOCATION: the summon location of the card
TRIGGERING_SUMMON_TYPE: its summon type
TRIGGERING_SUMMON_PROC_COMPLETE: if the card was properly summoned or not when it triggered the effect
TRIGGERING_SETCODES: the archetypes the card had when it activated the effect
2023-12-09 15:04:56 +01:00
Edoardo Lolletti
b85d41d8f7 Remove CHAININFO::CHAIN_COUNT
It was entirely redoundant as the info it returned are obtainable via Duel.GetCurrentChain in the case the passed index was 0, and in any other circumstance the returned information was needed already to call Duel.GetChainInfo in first place
2023-12-09 14:57:00 +01:00
Edoardo Lolletti
6dc321de75 Make LuaParamType an enum class 2023-12-08 19:55:50 +01:00
Edoardo Lolletti
ee73769591 Cleanup Duel.SwapControl 2023-12-08 19:52:46 +01:00
Edoardo Lolletti
cdb14fd115 Use lua_createtable instead of lua_newtable
Allows preallocating the needed size for its elements since they're known in advance
2023-12-08 12:30:10 +01:00
Edoardo Lolletti
06d8749f0c Make CHAININFO enum and no longer bitfield 2023-12-08 10:45:08 +01:00
Edoardo Lolletti
f079c3bdb4 Add CHAININFO_TRIGGERING_TYPE 2023-12-08 10:04:31 +01:00
Naim
198aac4ebb
Raise EVENT_CONFIRM and EVENT_TOHAND_CONFIRM from Duel.ConfirmCards (#152)
Import the changes from the script implementation for Duel.ConfirmCards.
It will now raise EVENT_CONFIRM whenever a card is revealed, and EVENT_TOHAND_CONFIRM whenever a card is revealed, the current event was EVENT_TO_HAND and it's currently in the hand, needed to interact with "Puppet King", "Puppet Queen" and "Vanquish Soul Jiaolong".

---------

Co-authored-by: Edoardo Lolletti <edoardo762@gmail.com>
2023-12-03 17:19:37 +01:00
Edoardo Lolletti
cb5516a931 Rename get_card_or_group and lua_tostring_or_empty
Use the lua_get prefix for consistency with the other higher level lua getters
2023-12-03 11:34:38 +01:00
Naim
12c9bdc3af
Update/Import new utilities from the lua scripting library (#151)
Added Duel.IsMainPhase, Duel.IsBatlePhase, Duel.IsPhase and Duel.IsTurnPlayer.

Update Card.IsCanBeEffectTarget: Prevent tokens that are no longer on the field from being valid cards for this function
2023-12-02 11:08:36 +01:00
Edoardo Lolletti
f89c5da422 Update get_card_or_group to return a pair group/card
To then be unpacked with c++ 17's structured binding
2023-11-26 17:47:46 +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
Naim
7ac33a959f
Update tribute related functions to support "Ritual Beast Ulti-Reirautari" (#150)
* Update Card.IsReleasable to accept a second, optional parameter for the reason. Update GetReleaseGroup, GetReleaseGroupCount the same way as well, with the new parameter being the 4th. Defaulting it to REASON_COST will prevent massive script changes (cards that tribute by effect already use Card.IsReleasableByEffect).

* Update EFFECT_CANNOT_RELEASE to pass the reason and the reason effect a 4th and 5th parameters to its target function

* Pass the reason down the line until get_release_list, check_release_list,is_player_can_release and card::is_releasable_by_nonsummon, updating internal function calls accordingly

---------

Co-authored-by: Edoardo Lolletti <edoardo762@gmail.com>
2023-11-12 17:04:20 +01:00
Edoardo Lolletti
863e534be3 Return `0` when short circuiting Duel.SSet 2023-09-24 16:45:39 +02:00
Edoardo Lolletti
f1288b638e Don't allow loading scripts if they contain a path separator 2023-07-29 13:48:31 +02:00
Naim
060f57d63d
Fix Duel.IsPlayerCanSendtoDeck (#144)
Fix Duel.IsPlayerCanSendtoDeck
2023-06-30 17:52:51 +02:00
Naim
43e2560378
Update Duel.Damage and Duel.Recover (#139)
Added an extra, optional parameter to allow the reason player to be manually set, if needed
2023-05-31 17:17:50 +02:00
Edoardo Lolletti
bc2b4b8dd7 Revert "Fix Duel.GetCardRaceFromCode"
This reverts commit 82cd6b695d.
2023-05-16 10:24:28 +02:00
Edoardo Lolletti
82cd6b695d Fix Duel.GetCardRaceFromCode
It was only returning returning the lower 32 bits of the race value, thus truncating higher races
2023-05-07 19:50:48 +02:00
Edoardo Lolletti
d9474f0551
Update Duel.AnnounceRace and Duel.AnnounceAttribute to handle new race (#136)
Do the required changes to make Duel.AnnounceRace work with the new types and also any possible newly added type removing some hardcodings down the way and adding some extra checks, also apply the same updates to Duel.AnnounceAttribute
2023-04-23 21:34:36 +02:00