Commit graph

588 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
dcd5023c70
Add DUEL_FAST_EFFECT_IGNITION and restore old behaviour of DUEL_OBSOLETE_IGNITION (#155)
DUEL_FAST_EFFECT_IGNITION will treat any ignition effect as fast effect if they're the first in a chain, to match GOAT rulings, DUEL_OBSOLETE_IGNITION instead, now renamed to DUEL_OCG_OBSOLETE_IGNITION will behave as before, with ignition effects being only activateable in response to a summon, as it worked in ocg's master rule 1
2025-03-29 13:00:50 +01:00
Edoardo Lolletti
c3b5a199b4 Pass the real "reason effect" when checking EFFECT_FUSION_MATERIAL
The effect will match the effect that is/will perform the summon
2024-12-23 17:56:51 +01:00
Edoardo Lolletti
ee5d6cd574 Remove GLOBALFLAG_SPSUMMON_COUNT
Its whole purpose was actually a pessimization, as it was guarding a 3 instructions compare with another 3 instructions compare
2024-11-04 22:36:53 +01:00
Edoardo Lolletti
2088372d4a Skip free chain effects in EVENT_PREDRAW 2024-08-14 11:35:22 +02:00
Edoardo Lolletti
9c1b301d79 Fix some EVENT_PHASE(_START) checks
Fixed the first in process_instant_event, where only the bits pertaining EVENT_PHASE_START were being checked, thus falsely filtering other events, similar case in process(Processors::AddChain)
2024-08-09 00:07:55 +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
e4fc37a4ca Minor updates 2024-04-02 14:02:23 +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
ffd8ec1349 Import c3efb49a27 2024-03-07 17:02:04 +01:00
Edoardo Lolletti
8c6237444e Fix crash in ForcedBattle due to altered `returns` state
If other processors were appended at the end of the battle step that could alter the returns buffer, the core could've interpreted the standalone battle phase not to have ended but instead another attack being declared or an effect being activated, thus possibly leading to an out of bound access
2024-03-03 12:58:36 +01:00
Edoardo Lolletti
62c2c5dbe2 Make Process::step unsigned
Avoid having to deal with UB while relying on signed integer overflow, add new value Processors::restart to be used in place of the -1 when "looping" a process (a value that when incremented by 1 will properly overflow to 0)
2024-02-11 13:38:26 +01:00
Edoardo Lolletti
a50505ea81 Update handling for EFFECT_MUST_ATTACK_MONSTER
Properly implement 58c488de9e:
 * If only one effect is providing EFFECT_MUST_ATTACK_MONSTER the attack selection proceeds as normal, with the turn player choosing the attack targets
 * If multiple effects are providing EFFECT_MUST_ATTACK_MONSTER, the opponent choose the attack target like it did prior to the other change, if then the EFFECT_MUST_ATTACK_MONSTER effect applied on the selected monster was also applying to other monsters, the turn player will then choose among those monsters a valid attack target
2024-02-10 11:34:42 +01:00
Edoardo Lolletti
58c488de9e Make the turn player choose the attack target when affected by EFFECT_MUST_ATTACK_MONSTER
The ruling got reverted, and now the attack target is no longer choosen by the opponent https://db.ygorganization.com/card#6922
2024-02-06 22:33:37 +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
c213bc5bdd Update instances where SortCard was being used
Don't assume 64 max entries sorted by that processor
2024-01-13 16:05:50 +01:00
Edoardo Lolletti
6aed4581d2 Reorder some structs 2024-01-13 15:59:28 +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
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
b931f3eb8c Fix half/double damage calculation from non piercing attacks 2023-12-10 11:41:25 +01:00
Edoardo Lolletti
0c003e98d8 Fix handling of piercing damage modifiers
Effect value is now properly full 64 bit, no longer static cast the double/half damage constants to int32
2023-12-09 11:21:50 +01:00
Edoardo Lolletti
6dc321de75 Make LuaParamType an enum class 2023-12-08 19:55:50 +01:00
Edoardo Lolletti
f47060eb43 Make select_chains and ignition_priority_chains lists
This allows to exchange the nodes with the other lists, thus removing unneded object copying
2023-11-26 17:48:20 +01:00
Edoardo Lolletti
816fe64199 Update emplace_back/back construct usage
Use c++17's return value on emplace_back
2023-11-26 17:47:47 +01:00
Edoardo Lolletti
5a696fb0ee Replace some begin/rbegin usage with front/back 2023-08-11 11:55:44 +02:00
Edoardo Lolletti
13ad895e15 Use normal replay handling on chain attacks with DUEL_STORE_ATTACK_REPLAYS 2023-08-09 11:38:09 +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
Edoardo Lolletti
cb350ca38e Remove some redoundancies and put them in field::reset_chain 2023-04-02 16:37:46 +02:00
Edoardo Lolletti
822b058985 Revert "Improve heuristics checking for EFFECT_TRAP_ACT_IN_HAND, EFFECT_QP_ACT_IN_NTPHAND, EFFECT_TRAP_ACT_IN_SET_TURN and EFFECT_QP_ACT_IN_SET_TURN prompts"
This reverts commit 825a530836.
2023-04-01 15:45:54 +02:00
Edoardo Lolletti
825a530836 Improve heuristics checking for EFFECT_TRAP_ACT_IN_HAND, EFFECT_QP_ACT_IN_NTPHAND, EFFECT_TRAP_ACT_IN_SET_TURN and EFFECT_QP_ACT_IN_SET_TURN prompts
If one of such effects has a condition or a target function, don't treat it as one of the generic ones
2023-03-15 22:02:44 +01:00
Edoardo Lolletti
6bc8e40736 Fix count limit not being checked for EFFECT_TRAP_ACT_IN_HAND, EFFECT_QP_ACT_IN_NTPHAND, EFFECT_TRAP_ACT_IN_SET_TURN and EFFECT_QP_ACT_IN_SET_TURN 2023-03-10 20:08:12 +01:00
Edoardo Lolletti
ad9f764db8 Fix issues caused by an uninitialized variable 2023-03-10 19:47:28 +01:00
Edoardo Lolletti
f69460bd0e Improve handling of EFFECT_TRAP_ACT_IN_HAND, EFFECT_QP_ACT_IN_NTPHAND, EFFECT_TRAP_ACT_IN_SET_TURN and EFFECT_QP_ACT_IN_SET_TURN
If one of such effect has no side effects (no count limit and no value function to execute) glob it with all the other effects, as whichever is picked won't affect the internal lua state and make the player choose the effect only when there is one of such effects that has a count limit or a function to execute.
2023-03-09 10:55:54 +01:00
Edoardo Lolletti
e73fb449a8 Silence downcast warnings 2023-02-07 16:43:27 +01:00
Edoardo Lolletti
53ae32a403 Fix changed routines in field::add_chain
The way they were changed made the core crash in the case of an EFFECT_ACTIVATE_COST being in play, reorder the sections so that first the EFFECT_TRAP_ACT_IN_HAND and co effects are evaluated and used, and then the cost is paid, so that there's no interference between it and the PROCESSOR_SELECT_OPTION
2022-12-28 23:39:04 +01:00
Edoardo Lolletti
3d6e55f56f Fixed regression that made any activated monster effect follow the path of spell/traps 2022-12-17 22:49:24 +01:00
Edoardo Lolletti
8ac2b665e2 Allow selecting which EFFECT_TRAP_ACT_IN_HAND, EFFECT_QP_ACT_IN_NTPHAND, EFFECT_TRAP_ACT_IN_SET_TURN and EFFECT_QP_ACT_IN_SET_TURN to use
The core will read those effects' descriptions and prompt the user in the case where multiple of them are available.
It will also call the value function of the choosen effect so that a possible callback is doable (might be changed to a better approach)
2022-12-17 20:03:31 +01:00
Edoardo Lolletti
a8186c9988 Take in account EFFECT_DRAW_COUNT under DUEL_DRAW_UNTIL_5 2022-11-26 18:09:21 +01:00
Edoardo Lolletti
4f4e783766 Duel.Overlay add parameter to automatically send xyz materials of the monsters to be attached to the grave
Implement it natively rather than via lua, correctly handle the scenario where one of the xyz monsters to be overlaid has an effect to banish any card sent to the grave and it would be still applying if duel.sendtograve was called manually from the script
2022-11-05 16:48:29 +01:00
Edoardo Lolletti
b1acec3de2 Revamp https://github.com/edo9300/ygopro-core/pull/19
Properly implement this thing by using a specific effect flag rather than randomly reading the effect value (that could have been set for other purposes)
2022-10-29 15:58:58 +02:00
Edoardo Lolletti
c4785633ba Remove undefined behaviour from ProgressiveBuffer class
Add a separate ``set`` function and use memcpy to store/retrieve the data in the buffer, removes the raw cast to a reference that could have also lead to aligment issues.
2022-09-17 15:19:38 +02:00
Edoardo Lolletti
77d7b786b9 Don't allow the player who's applying EFFECT_PATRICIAN_OF_DARKNESS to cancel the attack
Could be abused to stall indefinitely
2022-08-04 01:25:54 +02:00
Edoardo Lolletti
1718c8fccd Fix EFFECT_PATRICIAN_OF_DARKNESS with cards that can attack directly 2022-08-04 01:25:53 +02:00