Commit graph

2587 commits

Author SHA1 Message Date
Edoardo Lolletti
6c090348fe Update to actually standardized c++26 constructs 2026-02-23 23:45:52 +01:00
Edoardo Lolletti
5203fdf0ce Use c++26's refection to handle lua functions
[ci skip]
2026-02-23 23:44:54 +01:00
Edoardo Lolletti
4c5afac95f premake: Replace flags with appropriate function calls when available
Flags were deprecated and removed in recent premake versions
2026-02-20 11:24:53 +01:00
Edoardo Lolletti
400a541984 interpreter::pushobject: Use duel pointer from lua state rather than object being pushed i
Mitigates issue caused by moving around deleted effect objects, otherwise the push_weak_ref function would've been called on a garbage lua state pointer
2026-01-23 16:22:14 +01:00
Edoardo Lolletti
a30e6b75a9 Make effect's category 64 bits 2026-01-15 20:22:30 +01:00
Edoardo Lolletti
14646653ff Update license year 2026-01-15 20:22:30 +01:00
Edoardo Lolletti
0472feb468 Remove unused is_**_set_card functions 2025-12-05 21:14:15 +01:00
Edoardo Lolletti
e7f1199441 Goat: Fix ignition effs being usable on summons 2025-11-23 13:36:43 +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
7702a9fd92 Fix interaction with patrician and must attack
Currently, if both patrician of darkness and must attack effects were in play, th eturn player was still able to select an attack target among the monsters affected by the must attack effect, ignoring the selection performed by the opponent
2025-10-20 16:00:50 +02:00
Edoardo Lolletti
9a91d879c6 Add common-page-size linker flag for android aarch64
Other flag needed for 16kb aligned libs to work around possible linker bugs
2025-08-14 15:43:30 +02:00
Edoardo Lolletti
3aecb316f0 Don't send the code in MSG_SPSUMMONING if the card is facedown
Prevents leaking of private knowledge
2025-08-10 12:10:03 +02:00
Edoardo Lolletti
9174f58a5c Use -ffloat-store option when building lmathlib.c with mingw
This fixes the result of math.log with some powers of 2 not generating a whole number
2025-07-23 19:00:17 +02:00
Edoardo Lolletti
e2f5d6de3f Use a lua table to keep track of already loaded scripts
No longer use the handrolled partial hashmap
2025-07-12 22:28:56 +02:00
Edoardo Lolletti
b44812f4c9 Fix card::get_linked_zone passing a sequence too big to is_location_useable
The logic for how the function was called was wrong, issue found wth ubsan
2025-07-11 01:25:09 +02:00
Edoardo Lolletti
e3d36e6975 Remove unused card::is_summon_set_card 2025-07-11 00:31:45 +02:00
Edoardo Lolletti
64c630cbd9 Fix card::get_set_card not excluding effects meant for summon set card 2025-07-11 00:31:16 +02: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
de49f4b8e8 Support building with lua 5.5 2025-07-04 15:11:59 +02:00
Edoardo Lolletti
d6fe812a3b Fix building as c++20 and later 2025-07-04 15:11:51 +02:00
Edoardo Lolletti
53f1d159b7 Move to vs2022 runner
https://github.com/actions/runner-images/issues/12045
2025-06-29 12:06:12 +02:00
Edoardo Lolletti
828cb64de2 Pass the current battling cards as event group in EVENT_BATTLED 2025-06-28 20:13:43 +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
c79c54ede7 Don't leak OCGAPI macros from the header 2025-06-25 22:16:55 +02:00
Edoardo Lolletti
8c16a51db6 Add ocgapi_constants.h
Split actual constants exposed by the various core messages into a separate header file to make clear the fact those are the constants expected to be used by applications consuming the library
2025-06-25 21:39:39 +02:00
Edoardo Lolletti
e4c343cc21 Address various clang-20 warnings
Mostly extra semicolon warnings
2025-06-25 20:55:42 +02:00
Edoardo Lolletti
f639200ce2 Simplify the check for Processors::NeedsAnswer
Access the constexpr class value directly and update header includes in processor_unit.h
2025-06-23 22:31:23 +02:00
Edoardo Lolletti
e15b2d946e Fix compilation error due to low PROCESSOR_VARIANT_CAP
If PROCESSOR_VARIANT_CAP was set to a value which made the subvariants have Processors::SelectPlace and Processors::SelectDisField not be part of the same variant, emplacing a new variant object caused a compile error due to ambiguity on which variant to pick.
To fix this SelectDisField is no longer listed in the processor_unit tuple so that the base class will always be taken in consideration, this prevents `emplace_back(std::in_place_type<T>,` from being used tho when not using the subvariant approach.
2025-06-23 22:30:39 +02:00
Edoardo Lolletti
0fe394f34d Use std::memcpy 2025-06-13 19:47:35 +02:00
Edoardo Lolletti
872f7b01a7 Add explicit OCG_DuelCreationStatus values for null rng seed and wrong lua lib 2025-06-13 19:43:34 +02:00
Edoardo Lolletti
a5e62fb65e Reject rng seeds that are all zeros
closes https://github.com/edo9300/ygopro-core/issues/167
2025-06-12 22:41:08 +02:00
Edoardo Lolletti
53d74b1178 Add ndk 27 target with and build for riscv64 2025-06-06 18:46:29 +02:00
Edoardo Lolletti
20289d47b2 Update to lua 5.4.8 2025-06-06 13:01:48 +02:00
Edoardo Lolletti
f19efab792 Properly declare RACE_ALL constant 2025-06-05 23:28:24 +02:00
Edoardo Lolletti
920b8373f3 Allow RACE_YOKAI to be passed to announce race 2025-06-05 19:55:26 +02:00
Edoardo Lolletti
db6f9781f8 Update scriptlib::IsOwnedObject definition 2025-05-30 23:29:39 +02:00
Edoardo Lolletti
4ab85de875
Move Group's lifetime management to Lua (#166)
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.
2025-05-30 23:20:22 +02:00
Edoardo Lolletti
5628753a4f Default initialize tevent members 2025-05-30 21:42:20 +02:00
Edoardo Lolletti
0b31b9b56d Add Duel.GetReasonPlayer and GetReasonEffect 2025-05-29 22:27:08 +02:00
Edoardo Lolletti
2d72976984 Import https://github.com/Fluorohydride/ygopro-core/pull/752 2025-05-17 11:48:30 +02:00
Edoardo Lolletti
8104f31d69 Check at runtime for the lua library to be doing proper stack unwinding 2025-05-16 11:37:35 +02:00
Edoardo Lolletti
b468df11a7 Use initializer list to pass parameters to random's constructor 2025-05-16 10:41:17 +02:00
Edoardo Lolletti
b3abeec212 Add mingw32crtdll build target 2025-05-10 20:15:25 +02:00
Edoardo Lolletti
b3c846db2d Fix wrong filename in readme 2025-04-27 22:28:13 +02:00
Edoardo Lolletti
9cd09364ca Fix EFFECT_TOSS_COIN_REPLACE and EFFECT_TOSS_DICE_REPLACE not letting results be set
The results array wasn't being resized to allow for it to be then populated by SetCoinResult/SetDiceResult
2025-04-27 22:27:38 +02:00
Edoardo Lolletti
41f6e8901d Remove no longer present group.cpp from android makefile 2025-04-25 12:32:09 +02:00
Edoardo Lolletti
0a690c0467 Minor cleanups in group constructor
Remove redoundant rvalue constructor and remove separate group.cpp file by inlining the lua_obj constructor
2025-04-25 12:30:44 +02:00
Edoardo Lolletti
4e278a05ef Explicitly use lua_newuserdatauv with lua 5.4+ with 0 userdata value slots
In lua 5.4 and later, it's now possible to specify the number of userdata value slots, including 0, unlike in earlier versions where the slots were always fixed at 1.
Since they're unused in our case, use the full function to have 0 slots available and save some space for each userdata object
2025-04-25 12:05:00 +02:00
Edoardo Lolletti
640de69d6d Ensure that the Check/SelectWithSum functions don't receive groups with cards for which the operation value function returns 0
Prevents errors down the line due to overpaying since a card with sum_param of 0 will never contribute to the total and error out when the client sends a response
2025-04-25 11:57:30 +02:00