core: a card the waiting tag partner holds leaves its own list (TICKET-415, v1.4.1)
Release / windows (push) Successful in 38s
Release / android (push) Successful in 48s
Release / linux (push) Successful in 1m25s
Release / release (push) Successful in 6s
Release / attach-windows (push) Successful in 1s

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:
donnyandClaude Fable 5.1 committed 2026-10-16 13:38:08 -07:00
1 parent 65fcc307bb
commit 5286cb2bfd
5 files changed
+230 -2

No files matched your search

+9
View File
@@ -5,6 +5,15 @@ wire protocol, the engine message stream, the setup pairs and the Lua API. A row
change first shipped in the Unity repo, the ticket, and the contract part it touched. Rows 0001-0024
are the fork patches replayed into this repo as commits (`git log --oneline -- server/gframe core`).
## v1.4.1 — 2026-10-16
Tag: a card the waiting partner holds can be moved. No new export or capability bit: exports 335 / 856 /
850, protocol 9, capabilities `0x27FF`.
| Date | Change | Ticket | Contract part |
|---|---|---|---|
| 2026-10-16 | Fix in the core's tag lists (upstream code, reached through core patch 0015's swap order): an effect that keeps a card across the tag swap and 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) moved a card of `tag_list_main` / `tag_list_hand` / `tag_list_extra`; `remove_card` erased the ACTIVE list at the card's sequence, past the end of a shorter list (an empty Extra Deck: `memcpy` crash in `field::remove_card`) or the wrong card. Such a card now leaves the list that holds it (`field::tag_list_holding`) and goes where the move says; the next `MSG_TAG_SWAP` lists one card fewer. Core. | TICKET-415 | Engine message stream: `MSG_TAG_SWAP` (rules only) |
## v1.4.0 — 2026-10-16
Life points per side: the setup pair `ygol.side.b.lp=<n>` gives seat side B its own start LP. No new
+1 -1
View File
@@ -364,7 +364,7 @@ fork-related rows are marked.
| 142 | `MSG_ANNOUNCE_CARD` | `u8 player`; `n` x 4 | yes |
| 143 | `MSG_ANNOUNCE_NUMBER` | `u8 player`; `n` x 4 | yes |
| 160 | `MSG_CARD_HINT` | 9 | - |
| 161 | `MSG_TAG_SWAP` | `u8 player`, `u8 main count`, `u8 extra count`, `u8 extra pendulum count`, `u8 hand count`, `u32 top code`, then `u32` x hand, `u32` x extra. Not in `Scan` (the bot host never runs Tag). **Fork (core patch 0015): never emitted on a team's first turn; the first swap comes on turn 3 or later. v1.2.0: the server follows every swap with `STOC_TAG_PARTNER_CARDS` to the swapping side's two seats; v1.3.0: and to every observer when spectators see all.** | - |
| 161 | `MSG_TAG_SWAP` | `u8 player`, `u8 main count`, `u8 extra count`, `u8 extra pendulum count`, `u8 hand count`, `u32 top code`, then `u32` x hand, `u32` x extra. Not in `Scan` (the bot host never runs Tag). **Fork (core patch 0015): never emitted on a team's first turn; the first swap comes on turn 3 or later. v1.2.0: the server follows every swap with `STOC_TAG_PARTNER_CARDS` to the swapping side's two seats; v1.3.0: and to every observer when spectators see all. v1.4.1 (TICKET-415): a card an effect moves out of the waiting member's hand, deck or Extra Deck (one it kept across the swap, e.g. Time Fusion's Fusion) leaves that list, so the next swap lists one card fewer; its `MSG_MOVE` `from` sequence counts into the waiting list, not the active one.** | - |
| 162 | `MSG_RELOAD_FIELD` | `u8 duel rule`; per player: `u32 lp`, 7 monster zones (`u8 present`, +2 when present), 8 spell zones (`u8 present`, +1 when present), 6 count bytes; then ONE chain block `n` x 15 after both players. Produced by `query_field_info` and `Debug.ReloadFieldEnd()`; the server sends it as the 0005 field resync | - |
| 163 | `MSG_AI_NAME` | `u16 len` + bytes + 1 | - |
| 164 | `MSG_SHOW_HINT` | `u16 len` + bytes + 1 | - |
+182
View File
@@ -349,6 +349,7 @@ def main():
profile_suite(o.dll, port + 90)
attack_preview_suite(o.dll, port + 100)
tag_partner_suite(o.dll, port + 110)
tag_across_swap_suite(o.dll, port + 120)
print()
if failures:
print("FAILED: %d check(s)" % len(failures))
@@ -524,8 +525,13 @@ def make_workspace():
# v1.2.0 (TICKET-405): a Fusion monster, so a submitted deck has an Extra Deck
db.execute("INSERT INTO datas VALUES(?, 3, 0, 0, 65, 2000, 2000, 6, 1, 16, 0)", (PROBE_FUSION,))
db.execute("INSERT INTO texts VALUES(?, 'Probe Fusion', ''" + ", ''" * 16 + ")", (PROBE_FUSION,))
# TICKET-415: a Spell that keeps a card across the tag swap (its script is read from ./script)
db.execute("INSERT INTO datas VALUES(?, 3, 0, 0, 2, 0, 0, 0, 0, 0, 0)", (PROBE_TIME_FUSION,))
db.execute("INSERT INTO texts VALUES(?, 'Probe Time Fusion', ''" + ", ''" * 16 + ")", (PROBE_TIME_FUSION,))
db.commit()
db.close()
with open(os.path.join(root, "script", "c%d.lua" % PROBE_TIME_FUSION), "w", newline="\n") as f:
f.write(TIME_FUSION_LUA)
return root
@@ -2795,5 +2801,181 @@ def tag_partner_suite(dll_path, port):
tag_partner_room(dll_path, port + 1, "tag, hidden", hidden=True)
# --- TICKET-415: a card the waiting tag partner holds --------------------------------------------
# Time Fusion picks a Fusion from the Extra Deck and Summons it at the team's next Standby Phase. By
# then the partners have swapped: the Fusion sits in the waiting partner's tag_list_extra, and the core
# erased the ACTIVE Extra Deck at its sequence (past the end of an empty one: the Editor crash of
# 2026-10-16). The fixed core takes the card out of the list that holds it.
PROBE_TIME_FUSION = PROBE_CARD + 700
MSG_RETRY, MSG_SELECT_CARD, MSG_SELECT_POSITION, MSG_SPSUMMONING, MSG_NEW_TURN = 1, 15, 19, 62, 40
MSG_SELECT_EFFECTYN, MSG_SELECT_YESNO, MSG_SELECT_OPTION, MSG_SELECT_DISFIELD, MSG_SELECT_TRIBUTE = 12, 13, 14, 24, 20
TIME_FUSION_LUA = """--Probe Time Fusion (TICKET-415): banish 1 other card from the hand; pick 1 Fusion Monster in the Extra Deck.
--During the next Standby Phase of the player who activated this: Special Summon that Fusion Monster.
local s,id,o=GetID()
function s.initial_effect(c)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCost(s.cost)
e1:SetTarget(s.target)
e1:SetOperation(s.activate)
c:RegisterEffect(e1)
end
function s.costfilter(c)
return c:IsAbleToRemoveAsCost()
end
function s.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(s.costfilter,tp,LOCATION_HAND,0,1,e:GetHandler()) end
local g=Duel.SelectMatchingCard(tp,s.costfilter,tp,LOCATION_HAND,0,1,1,e:GetHandler())
Duel.Remove(g,POS_FACEUP,REASON_COST)
end
function s.ffilter(c)
return c:IsType(TYPE_FUSION)
end
function s.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(s.ffilter,tp,LOCATION_EXTRA,0,1,nil) end
end
function s.activate(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.SelectMatchingCard(tp,s.ffilter,tp,LOCATION_EXTRA,0,1,1,nil):GetFirst()
if not tc then return end
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_PHASE+PHASE_STANDBY)
e1:SetCountLimit(1)
e1:SetLabelObject(tc)
e1:SetCondition(s.spcon)
e1:SetOperation(s.spop)
e1:SetReset(RESET_PHASE+PHASE_STANDBY+RESET_SELF_TURN)
Duel.RegisterEffect(e1,tp)
end
function s.spcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetTurnPlayer()==tp
end
function s.spop(e,tp,eg,ep,ev,re,r,rp)
local tc=e:GetLabelObject()
if tc:IsLocation(LOCATION_EXTRA) then
Duel.SpecialSummon(tc,0,tp,tp,true,false,POS_FACEUP)
end
end
"""
def first_free_zone(d):
# MSG_SELECT_PLACE / DISFIELD: player, min, u32 flag (a set bit = that zone is NOT available)
player = d[1]
(flag,) = struct.unpack_from("<I", d, 3)
for side in (0, 1):
for seq in range(7):
if not flag & (1 << (side * 16 + seq)):
return bytes([player if side == 0 else 1 - player, 0x04, seq])
for seq in range(8):
if not flag & (1 << (side * 16 + 8 + seq)):
return bytes([player if side == 0 else 1 - player, 0x08, seq])
return bytes([player, 0x04, 0])
def tag_across_swap_room(dll_path, port, label):
print("== tag card across the swap, %s (TICKET-415: seat 3 picks its Fusion on turn 4; the team's next Standby Phase is seat 2's turn 6, whose Extra Deck is empty)" % label)
root = make_workspace()
here = os.getcwd()
os.chdir(root)
try:
write_special(root, [])
dll, thread = host_dll(dll_path, port, 2)
seated = []
for i in range(4):
c = Client("127.0.0.1", port, "ts-seat%d" % i)
c.log = list(c.join())
seated.append(c)
check([c.seat for c in seated] == [0, 1, 2, 3], "%s: four seats (%r)" % (label, [c.seat for c in seated]))
drain_all(seated)
decks = {0: [PROBE_CARD] * 40, 1: [PROBE_CARD] * 40, 2: [PROBE_CARD] * 40, 3: [PROBE_TIME_FUSION] * 40 + [PROBE_FUSION]}
for c in seated:
c.send(CTOS_UPDATE_DECK, deck_bytes(decks[c.seat]))
pump(seated, lambda: False, limit=0.8)
seated[0].send(CTOS_HS_START)
state = {"turn": 0, "activated": False, "retries": 0, "summoned": [], "idle_after_summon": 0, "swap8": None}
def answer(c, payload):
c.send(CTOS_TIME_CONFIRM)
c.send(CTOS_RESPONSE, payload)
def play(until, limit):
deadline = time.time() + limit
while time.time() < deadline:
for c in seated:
for pid, d in c.drain(quiet=0.02, limit=0.2):
c.log.append((pid, d))
if pid == STOC_SELECT_TP:
c.send(CTOS_TP_RESULT, bytes([1 if c.seat == 0 else 0])) # side A (seats 0 + 1) goes first
continue
if pid != 0x01 or not d:
continue
t = d[0]
if t == MSG_NEW_TURN and c.seat == 0:
state["turn"] += 1
elif t == MSG_TAG_SWAP and c.seat == 2 and d[1] == 1 and state["turn"] == 8:
state["swap8"] = d
elif t == MSG_SPSUMMONING and c.seat == 2:
state["summoned"].append((state["turn"], struct.unpack_from("<I", d, 1)[0]))
elif t == MSG_RETRY:
state["retries"] += 1
elif t == MSG_SELECT_IDLECMD:
n = 2
for k in range(5):
n += 1 + d[n] * 7
activatable = d[n]
if c.seat == 3 and activatable and not state["activated"]:
state["activated"] = state["turn"]
answer(c, struct.pack("<i", 5)) # activate the first card: the Spell
else:
if c.seat == 2 and state["summoned"]:
state["idle_after_summon"] += 1
answer(c, struct.pack("<i", 7)) # to the End Phase
elif t in (MSG_SELECT_CARD, MSG_SELECT_TRIBUTE):
answer(c, bytes([1, 0]))
elif t == MSG_SELECT_CHAIN:
answer(c, struct.pack("<i", -1))
elif t in (MSG_SELECT_PLACE, MSG_SELECT_DISFIELD):
answer(c, first_free_zone(d))
elif t == MSG_SELECT_POSITION:
answer(c, struct.pack("<i", next(b for b in (1, 2, 4, 8) if d[6] & b)))
elif t in (MSG_SELECT_EFFECTYN, MSG_SELECT_YESNO):
answer(c, struct.pack("<i", 1))
elif t in (MSG_SELECT_OPTION, MSG_SELECT_BATTLECMD):
answer(c, struct.pack("<i", 0 if t == MSG_SELECT_OPTION else 3))
if until():
return True
if any(c.closed for c in seated):
return False
return until()
ok = play(lambda: state["turn"] >= 6 and state["idle_after_summon"] >= 1, limit=40)
check(state["activated"] == 4, "%s: seat 3 activated the Spell on turn 4, its first turn (turn %s)" % (label, state["activated"]))
check(ok, "%s: turn 6 (seat 2's second turn) played on: the engine survived the Standby Phase" % label)
check(state["summoned"] == [(6, PROBE_FUSION)], "%s: the Fusion seat 3 picked was Special Summoned in seat 2's Standby Phase of turn 6, out of the waiting partner's Extra Deck (%s)" % (label, state["summoned"]))
check(state["retries"] == 0, "%s: no answer was refused (MSG_RETRY x%d)" % (label, state["retries"]))
ok = play(lambda: state["swap8"] is not None, limit=20)
check(ok and state["swap8"] is not None and state["swap8"][3] == 0, "%s: the swap of turn 8 brings seat 3 back with an empty Extra Deck: the Fusion left the list that held it (%s)" % (label, None if state["swap8"] is None else state["swap8"][3]))
check(all(not c.closed for c in seated), "%s: every seat is still connected" % label)
marks = marks_of(seated)
for c in seated[:2]:
c.send(CTOS_SURRENDER)
ok = pump(seated, lambda: all(match_overs(since(c, marks)) for c in seated), limit=10)
check(ok, "%s: side 0 surrendered: MATCH_OVER reached everyone" % label)
for c in seated:
c.close()
stop_dll(dll, thread, label)
finally:
os.chdir(here)
shutil.rmtree(root, ignore_errors=True)
def tag_across_swap_suite(dll_path, port):
print()
print("hosting the tag card across the swap room from %s" % dll_path)
tag_across_swap_room(dll_path, port, "tag")
if __name__ == "__main__":
sys.exit(main())
+37 -1
View File
@@ -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) {
+1
View File
@@ -424,6 +424,7 @@ public:
void swap_deck_and_grave(uint8_t playerid);
void reverse_deck(uint8_t playerid);
void refresh_player_info(uint8_t playerid);
card_vector* tag_list_holding(card* pcard); // [YGOL] TICKET-415
void tag_swap(uint8_t playerid);
void add_effect(effect* peffect, uint8_t owner_player = PLAYER_NONE);