From fe4fe998cd92373b00ac20d1a0d6dc32e316b6a9 Mon Sep 17 00:00:00 2001 From: Tyler Spivey Date: Thu, 1 Feb 2024 11:02:56 -0800 Subject: [PATCH] Support new ygopro core The new core starting from 16c4d4b255aebafcb76763ea627d5bd302ac636d has a different API. --- duel_build.py | 4 ++-- ygo/utils.py | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/duel_build.py b/duel_build.py index 5303085..5cc43ba 100644 --- a/duel_build.py +++ b/duel_build.py @@ -85,7 +85,7 @@ typedef uint32 (*card_reader)(uint32, struct card_data*); void set_card_reader(card_reader f); typedef byte* (*script_reader)(const char*, int*); -typedef uint32 (*message_handler)(void*, uint32); +typedef uint32 (*message_handler)(intptr_t, uint32); extern "Python" uint32 message_handler_callback (void *, int32); void set_message_handler(message_handler f); extern "Python" byte *script_reader_callback(const char *, int *); @@ -95,7 +95,7 @@ void end_duel(ptr pduel); void get_log_message(ptr pduel, byte* buf); int32 get_message(ptr pduel, byte* buf); -int32 process(ptr pduel); +uint32 process(ptr pduel); void new_card(ptr pduel, uint32 code, uint8 owner, uint8 playerid, uint8 location, uint8 sequence, uint8 position); void new_tag_card(ptr pduel, uint32 code, uint8 owner, uint8 location); void set_player_info(ptr pduel, int32 playerid, int32 lp, int32 startcount, int32 drawcount); diff --git a/ygo/utils.py b/ygo/utils.py index dc3b279..60bbd98 100644 --- a/ygo/utils.py +++ b/ygo/utils.py @@ -13,6 +13,9 @@ except ImportError: DUEL_AVAILABLE = False +PROCESSOR_FLAG = 0xf0000000 +PROCESSOR_END = 0x20000000 + def parse_lflist(filename): lst = {} @@ -36,9 +39,10 @@ def parse_lflist(filename): def process_duel(d): while d.started: res = d.process() - if res & 0x20000: + flag = res & PROCESSOR_FLAG + if flag & PROCESSOR_END: break - elif res & 0x10000 and res != 0x10000: + elif flag == 0x10000000: if d.keep_processing: d.keep_processing = False continue