core: a card the waiting tag partner holds leaves its own list (TICKET-415, v1.4.1)
The Editor crashed in a Tag duel at a turn change: field::remove_card erased list_extra past its end (memcpy off the vector) from move_to_field. Reproduced outside Unity with the four real decks: Zane's Time Fusion (810000954) picks a Fusion from the Extra Deck on his turn and Summons it "during your next Standby Phase"; by then the partners have swapped, the Fusion sits in tag_list_extra (still LOCATION_EXTRA, sequence into THAT list), and remove_card erased the ACTIVE Extra Deck at that sequence: Adrian's is empty, so the erase ran past the end. With a longer active list it silently dropped the wrong card. The core is upstream's here; the fork's swap order (core patch 0015) only decides which turn it lands on. - field::tag_list_holding(card*): the tag_list_main / hand / extra of the card's controller that holds it, else null (Tag duels only). - remove_card: such a card is erased from that list, the list's sequences are renumbered, STATUS_TO_HAND_WITHOUT_CONFIRM and tag_extra_p_count are kept honest; move_card never treats it as a same-location reorder, so it goes through remove_card + add_card like any other move. - Probe: tag_across_swap_suite hosts a Tag room where seat 3's "Probe Time Fusion" (a workspace script) picks its Fusion on turn 4 and seat 2, with an empty Extra Deck, reaches its Standby Phase on turn 6: the Fusion is Summoned, the duel plays on, no MSG_RETRY, and turn 8's MSG_TAG_SWAP brings seat 3 back with an empty Extra Deck. The shipped v1.4.0 engine dies in this case. - CHANGELOG v1.4.1 row; contract note on MSG_TAG_SWAP (the next swap lists one card fewer; MSG_MOVE's from-sequence counts into the waiting list). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
65fcc307bb
commit
5286cb2bfd
5 files changed
+230
-2
No files matched your search
+37
-1
@@ -205,6 +205,16 @@ void field::remove_card(card* pcard) {
|
||||
if (!check_playerid(pcard->current.controler) || pcard->current.location == 0)
|
||||
return;
|
||||
uint8_t playerid = pcard->current.controler;
|
||||
if(card_vector* tag_list = tag_list_holding(pcard)) { // [YGOL] TICKET-415, see tag_list_holding
|
||||
tag_list->erase(std::find(tag_list->begin(), tag_list->end(), pcard));
|
||||
uint8_t seq = 0;
|
||||
for(auto& tcard : *tag_list)
|
||||
tcard->current.sequence = seq++;
|
||||
if(pcard->current.location == LOCATION_HAND)
|
||||
pcard->set_status(STATUS_TO_HAND_WITHOUT_CONFIRM, FALSE);
|
||||
else if(pcard->current.location == LOCATION_EXTRA && (pcard->data.type & TYPE_PENDULUM) && (pcard->current.position & POS_FACEUP))
|
||||
--player[playerid].tag_extra_p_count;
|
||||
} else
|
||||
switch (pcard->current.location) {
|
||||
case LOCATION_MZONE:
|
||||
player[playerid].list_mzone[pcard->current.sequence] = 0;
|
||||
@@ -259,7 +269,7 @@ void field::move_card(uint8_t playerid, card* pcard, uint8_t location, uint8_t s
|
||||
pcard->sendto_param.position = POS_FACEDOWN_DEFENSE;
|
||||
}
|
||||
if (pcard->current.location) {
|
||||
if (pcard->current.location == location && pcard->current.pzone == !!pzone) {
|
||||
if (pcard->current.location == location && pcard->current.pzone == !!pzone && !tag_list_holding(pcard)) { // [YGOL] TICKET-415
|
||||
if (pcard->current.location == LOCATION_DECK) {
|
||||
if(preplayer == playerid) {
|
||||
pduel->write_buffer8(MSG_MOVE);
|
||||
@@ -1146,6 +1156,32 @@ void field::refresh_player_info(uint8_t playerid) {
|
||||
}
|
||||
player[playerid].used_location = used_flag;
|
||||
}
|
||||
// [YGOL] TICKET-415: the lists of the waiting tag partner (tag_list_main / tag_list_hand / tag_list_extra)
|
||||
// hold cards that still say LOCATION_DECK / HAND / EXTRA with a sequence into THAT list. An effect that
|
||||
// kept a card across the tag swap moves it later (Time Fusion: the Fusion picked from the Extra Deck at
|
||||
// activation, Summoned at the team's next Standby Phase, when the partner's Extra Deck is the active one);
|
||||
// remove_card then erased the ACTIVE list at the card's sequence: past the end of a shorter list (an
|
||||
// empty Extra Deck: the owner's crash) or the wrong card. Such a card leaves the list that holds it.
|
||||
card_vector* field::tag_list_holding(card* pcard) {
|
||||
if(!(core.duel_options & DUEL_TAG_MODE) || !check_playerid(pcard->current.controler))
|
||||
return nullptr;
|
||||
auto& p = player[pcard->current.controler];
|
||||
card_vector* tag_list = nullptr;
|
||||
switch(pcard->current.location) {
|
||||
case LOCATION_DECK:
|
||||
tag_list = &p.tag_list_main;
|
||||
break;
|
||||
case LOCATION_HAND:
|
||||
tag_list = &p.tag_list_hand;
|
||||
break;
|
||||
case LOCATION_EXTRA:
|
||||
tag_list = &p.tag_list_extra;
|
||||
break;
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
return std::find(tag_list->begin(), tag_list->end(), pcard) != tag_list->end() ? tag_list : nullptr;
|
||||
}
|
||||
void field::tag_swap(uint8_t playerid) {
|
||||
//main
|
||||
for(auto& pcard : player[playerid].list_main) {
|
||||
|
||||
Reference in new issue
Block a user