Commit graph

93 commits

Author SHA1 Message Date
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
f77ff14eca Allow adding cards to the duel with locaton 0
Used for duel rule cards
2025-04-24 22:24:35 +02:00
Edoardo Lolletti
f0aecd3e8d Fix wrong merge 2025-04-06 20:28:55 +02:00
Edoardo Lolletti
13e06bbf4b
Pass structs by pointers to the ocgapi (#148)
Passing structs by value doesn't guarantee a stable abi
2025-04-06 20:26:12 +02:00
Edoardo Lolletti
73560d0f72 Ensure that exactly 1 location is passed to the ocgapi functions
The only exception is for functions accounting for LOCATION_OVERLAY, in which case the 1 location is enforced but ignoring that flag
2025-03-22 20:18:30 +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
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
b7893b6408 Add NoInline define and rename __forceinline
Define __forceinline as ForceInline
2023-12-24 17:47:19 +01:00
Edoardo Lolletti
76020da04a Minor function signatures updates and ocgapi cleanup 2023-07-24 13:57:39 +02:00
Edoardo Lolletti
b43ee438ba Minor cleanup in some functions 2023-03-04 19:48:07 +01:00
Edoardo Lolletti
e73fb449a8 Silence downcast warnings 2023-02-07 16:43:27 +01:00
Edoardo Lolletti
34c26df189 Use the integer signedness in the msg_reload_field returned by OCG_DuelQueryField 2022-10-22 20:11:12 +02:00
Edoardo Lolletti
4da35cb7f1 Use preincrement operator instead of postincrement in the codebase
Semantically the proper operator to use for oneline increments is the preincrement one, the postincrement is the one to be used only in teh cases where the previous value is required.
2022-03-05 13:56:43 +01:00
Edoardo Lolletti
32680956ca Allocate duel class with std::nothrow
Make so new doesnt throw std::bad_alloc and returns nullptr on failure. Without this, the below check was completely pointless
2021-12-07 13:48:04 +01:00
Edoardo Lolletti
ae0f4efff9 Initialize duel and other subclass in their constructors directly
Don't create the class and set the values afterwards, directly set the appropriate values passed in OCG_DuelOptions in the constructor itself
2021-12-07 13:34:38 +01: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
2d71261f50 Minor cleanup to OCG_DuelNewCard 2021-09-04 20:46:55 +02:00
edo9300
771cf12b7e Fix some visual studio warnings 2020-11-07 19:47:50 +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
4393d2cca4 Fix minor issues when checking for EFFECT_EXTRA_RELEASE_NONSUM in select_release_cards 2020-08-25 00:45:13 +02:00
edo9300
f841a50605 Minor cleanups
Check for location and team validity in OCG_DuelQueryLocation, remove some minor warnings
2020-08-23 18:06:51 +02:00
edo9300
f137ca6407 Function signatures formatting 2020-07-21 19:15:19 +02:00
edo9300
327ab2d432 Update startup process and remove redounant pduel->game_field-> 2020-04-20 09:03:27 +02:00
edo9300
216c461136 Make buffer passed in OCG_DuelSetResponse const 2020-02-07 20:17:51 +01:00
edo9300
8a6751bcbe Revert "Remove OCG_CardData parameter from OCG_DataReaderDone"
This reverts commit ac8d377705.
2020-02-07 20:10:59 +01: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
ac8d377705 Remove OCG_CardData parameter from OCG_DataReaderDone 2020-01-13 21:44:16 +01:00
edo9300
5434d89338 Changed internal handling of cards data, allow unlimited amount of setcodes per card at creation 2020-01-13 20:03:14 +01:00
Edoardo
0f27edb74c Fixed malformed query message on posix systems 2019-09-22 00:34:28 +02:00
Dylam De La Torre
39dda6ee8b remove unused return value from OCG_StartDuel 2019-09-18 22:57:09 +02:00
Dylam De La Torre
f78d3192cb make OCG_CreateDuel set duel to nullptr on failure
also make OCG_DestroyDuel a no-op in case of nullptr
2019-09-12 17:18:20 +02:00
Dylam De La Torre
b065dba936 fix default log handler signature and remove cast 2019-09-12 17:16:29 +02:00
edo9300
d9a1c047c6 OCG_DuelQueryLocation was putting the length at the end instead of the beginning 2019-09-09 09:51:53 -04:00
edo9300
5da60ee2c4 rename neo_ocgapi to ocgapi 2019-09-09 09:51:53 -04:00
edo9300
99c32938f6 Finished cleanup of older api functions 2019-09-09 09:51:29 -04:00
edo9300
63b6a9fdbd Implement OCG_DuelQuery, OCG_DuelQueryLocation, OCG_DuelQueryField, updated MSG_RELOAD_FIELD 2019-09-09 09:51:29 -04:00
edo9300
967f9b89f7 Removed duel_rule property from duel 2019-09-09 09:51:28 -04:00
edo9300
119cbc5f00 Added EVENT_STARTUP 2019-08-22 15:43:10 +02:00
edo9300
34282c7155 Added small class "duel_message" to handle the various messages sent from the core and not making it work directly on the buffer 2019-07-16 00:57:53 +02:00
kevinlul
ff114fccfe Convert instance of size_t to size_type 2019-06-20 10:32:10 -04:00
edo9300
5567682487 Changed handling of tag duels and relay duels
Unified new card functions under new_card, with an additional parameter (duelist). This parameter will be used to add any "additional" player, like a partner in a tag duel or in a relay duel, the api will automatically handle the various modes, if DUEL_RELAY_MODE is passed then the extra players will be considered like in a relay duel, otherwise the extra players will play in rotation like in a tag duel.
2019-06-02 19:41:06 +02:00
edo9300
097eafa127 Add memcpy check with len = 0 when reasing buffer from the api 2019-06-01 12:42:49 +02:00
edo9300
50da92e90b Cleanup
Added is_flag funciton to check for duel flags, instead of manually doing the bitwise operation. added get_pzone_index, removing teh ugly checks like "!(pduel->game_field->core.duel_options & DUEL_SEPARATE_PZONE) ? (pduel->game_field->core.duel_options & SPEED_DUEL) ? (sequence == 0) ? 1 : 3 : sequence * 4 : (6 + sequence)". More function cleanup in field::filter_matching_card
2019-05-02 01:05:06 +02:00
edo9300
5c1536bf0f Updated game messages values
MSG_SELECT_BATTLECMD, MSG_SELECT_IDLECMD, MSG_SELECT_SUM, MSG_SELECT_CHAIN, MSG_SORT_CARD, MSG_SORT_CHAIN, MSG_CONFIRM_DECKTOP, MSG_CONFIRM_EXTRATOP, MSG_CONFIRM_CARDS,
MSG_SHUFFLE_HAND, MSG_SHUFFLE_EXTRA, MSG_CARD_SELECTED, MSG_RANDOM_SELECTED, MSG_BECOME_TARGET, MSG_DRAW:
Changed card counts values from int8 to int32.

MSG_SELECT_SUM, MSG_SELECT_CARD, MSG_SELECT_TRIBUTE, MSG_SELECT_UNSELECT_CARD:
Changed max and min value from int8 to int32

MSG_DECK_TOP, MSG_CHAINING:
Changed card sequence from int8 to int32.

MSG_TAG_SWAP:
Changed card counts values from int8 to int32.

MSG_RELOAD_FIELD:
Changed card counts values from int16 to int32.
2019-04-18 13:16:56 +02:00
edo9300
ca1363aca9 Removed 64 bytes response buffer limitation
Removed 64 bytes response buffer limitation, atm it's only used for card selection return buffers. Updated api version to 1.1
2019-03-17 01:05:58 +01:00
edo9300
a5f52f8b4c Updated internal api buffer handling, added versioning
Replaced the buffer internally used by teh api with a vector of chars, updated the api functions for queries and duel buffer to have the possibility to get the length of the buffer before actually reading it, added api versioning to keep track of compatibilities if used as dynamic object
2019-03-16 20:08:08 +01:00
Dylam De La Torre
af09328d08 make api duel creation/deletion thread-safe 2019-02-01 14:32:33 +01:00
edo9300
94a7606d55 Replaced mtrandom.h with c++ library "random" 2019-01-12 22:21:57 +01:00
edo9300
7a27292fbf Fixed default script reader
Was missing a final slash in the script path
2019-01-07 23:08:07 +01:00