Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
10ade7fc41 | ||
|
|
5286cb2bfd |
No files matched your search
@@ -5,6 +5,24 @@ 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.2 — 2026-10-24
|
||||
|
||||
Tag partner cards follow every change. Same message, same payload, no new export or capability bit:
|
||||
exports 335 / 856 / 850, protocol 9, capabilities `0x27FF`.
|
||||
|
||||
| Date | Change | Ticket | Contract part |
|
||||
|---|---|---|---|
|
||||
| 2026-10-24 | `STOC_TAG_PARTNER_CARDS 0x5F` has a fourth send point: after every engine batch (beside `FlushDeckLists`, not when the duel ended) `TagDuel::FlushTagPartnerCards` queries `ygol_query_tag_cards` per side and broadcasts it when the bytes differ from the last broadcast for that side (a Summon out of the waiting member's Extra Deck, Time Fusion), to the same receivers. Every broadcast (start, swap, change) records its bytes; a resync to one player does not. Server. | TICKET-424 | Wire `0x5F` |
|
||||
|
||||
## 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
|
||||
|
||||
@@ -214,7 +214,7 @@ duelist's own side (v1.2.0), both sides for an observer when spectators see all
|
||||
| `0x5C` | `STOC_DECK_LIST` | `STOC_DeckList` (5): `u8 version` (1), `u8 side`, `u8 kind`, `u16 count`, then `u32 codes[count]` | No | Kind 0 (the deck's remaining cards, SORTED) to its owner (both teammates in Tag); kind 1 (real order, top first) and kind 2 (the submitted Main Deck of the duelist whose deck is in the zone, sorted) to observers only when spectators see all. Sent when a list differs from the last one that audience got; in the late-watcher snapshot | `0x100` | 6 | 0019 |
|
||||
| `0x5D` | `STOC_PROFILE` | `u16 sender` + `CTOS_Profile` (100) | Yes | Everyone; stored per seat, in the snapshot after APPEARANCE, swapped with the seat, kept across the 0014 lobby reset, cleared when the seat empties | `0x200` | 7 | 0020 |
|
||||
| `0x5E` | `STOC_ATTACK_PREVIEW` | `u8 version` (1), `u8 count`, then per pair the 4 ask bytes echoed + the 24-byte `ygol_preview_attack` answer | No | The asker only. Only attackers the open prompt listed; a pair the engine refuses is left out (the count shrinks); a valid ask whose every pair is left out still gets count 0 | `0x400` | 8 | 0023 |
|
||||
| `0x5F` | `STOC_TAG_PARTNER_CARDS` | `u8 side` + the `ygol_query_tag_cards` bytes (7 + 4 x the three counts) | No | The two seats of `side`, never the other team. Sent after `start_duel` (the waiting members' opening hands), after every `MSG_TAG_SWAP` for the side that swapped (the member that just left is the waiting one), and to a seated duelist in its field resync (`CTOS_REQUEST_FIELD`, after the `MSG_RELOAD_FIELD`). **v1.3.0 (TICKET-412): when spectators see all (no `ygol.room.spectatorview=hidden`), every observer gets the same bytes for BOTH sides at the start and after every swap, and an observer's field resync and a late watcher's snapshot carry both sides (after the deck lists); with the pair, an observer never gets one.** Tag rooms only; a Single / Match room never sends it | `0x2000` | 9 | v1.2.0, v1.3.0 |
|
||||
| `0x5F` | `STOC_TAG_PARTNER_CARDS` | `u8 side` + the `ygol_query_tag_cards` bytes (7 + 4 x the three counts) | No | The two seats of `side`, never the other team. Sent after `start_duel` (the waiting members' opening hands), after every `MSG_TAG_SWAP` for the side that swapped (the member that just left is the waiting one), and to a seated duelist in its field resync (`CTOS_REQUEST_FIELD`, after the `MSG_RELOAD_FIELD`). **v1.3.0 (TICKET-412): when spectators see all (no `ygol.room.spectatorview=hidden`), every observer gets the same bytes for BOTH sides at the start and after every swap, and an observer's field resync and a late watcher's snapshot carry both sides (after the deck lists); with the pair, an observer never gets one.** **v1.4.2 (TICKET-424): after every engine batch (beside the deck lists, not when the duel ended), a side whose bytes differ from the last ones broadcast for it is sent again to the same receivers (an effect that moves a waiting member's card mid-turn); every broadcast records its bytes, so a swap is never sent twice; a resync to one player does not record.** Tag rooms only; a Single / Match room never sends it | `0x2000` | 9 | v1.2.0, v1.3.0, v1.4.2 |
|
||||
|
||||
### Capability bits and protocol numbers
|
||||
|
||||
@@ -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 | - |
|
||||
|
||||
@@ -143,6 +143,12 @@
|
||||
# side B won the toss), and the replay has flag 0x20000000 with the same two
|
||||
# values after opt. Every other room's replay has no such flag.
|
||||
#
|
||||
# With --dll it also gates v1.4.2 (TICKET-424, tag partner cards on change): in
|
||||
# the TICKET-415 room the Fusion seat 3 picked leaves seat 3's Extra Deck in
|
||||
# seat 2's Standby Phase of turn 6, while seat 3 waits; between that
|
||||
# MSG_SPSUMMONING and the next MSG_TAG_SWAP seats 2 and 3 get exactly one
|
||||
# TAG_PARTNER_CARDS, for side 1 with an empty Extra Deck, and seats 0 and 1 none.
|
||||
#
|
||||
# Exit 0 only when every check passed. Stock DLL: the first check fails; the
|
||||
# 0011 DLL fails at the capability flags.
|
||||
import argparse, base64, ctypes, lzma, os, shutil, socket, sqlite3, struct, sys, tempfile, threading, time
|
||||
@@ -349,6 +355,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 +531,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 +2807,193 @@ 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]))
|
||||
for c in seated:
|
||||
# TICKET-424: the waiting member's Extra Deck changed mid-turn, so its side's seats get the new bytes once
|
||||
log = c.log
|
||||
start = next((i for i, (p, d) in enumerate(log) if p == 0x01 and d and d[0] == MSG_SPSUMMONING and struct.unpack_from("<I", d, 1)[0] == PROBE_FUSION), None)
|
||||
if not check(start is not None, "%s: seat %d saw the Fusion's MSG_SPSUMMONING" % (label, c.seat)):
|
||||
continue
|
||||
end = next((i for i in range(start + 1, len(log)) if log[i][0] == 0x01 and log[i][1] and log[i][1][0] == MSG_TAG_SWAP), len(log))
|
||||
got = partner_cards(log[start + 1:end])
|
||||
if c.seat >= 2:
|
||||
check(len(got) == 1 and got[0][0] == 1 and got[0][3] == [], "%s: seat %d got exactly one TAG_PARTNER_CARDS after the Summon out of the waiting partner's Extra Deck, side 1 with an empty Extra Deck (%s)" % (label, c.seat, [(g[0], g[3]) for g in got]))
|
||||
else:
|
||||
check(not got, "%s: seat %d (the other team) got no TAG_PARTNER_CARDS for the change (%d)" % (label, c.seat, len(got)))
|
||||
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
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1384,6 +1384,7 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
|
||||
RefreshExtra(0);
|
||||
RefreshExtra(1);
|
||||
start_duel(pduel, opt);
|
||||
tag_cards_known[0] = tag_cards_known[1] = false;
|
||||
SendTagPartnerCards(0); // YGOL tag partner cards: the waiting members' opening hands
|
||||
SendTagPartnerCards(1);
|
||||
if(host_info.time_limit) {
|
||||
@@ -1420,8 +1421,10 @@ void TagDuel::Process() {
|
||||
stop = Analyze(engineBuffer.data(), engLen);
|
||||
}
|
||||
}
|
||||
if(stop != 2) // YGOL deck lists: after every engine batch, before a prompt waits
|
||||
if(stop != 2) { // YGOL deck lists + tag partner cards: after every engine batch, before a prompt waits
|
||||
FlushDeckLists();
|
||||
FlushTagPartnerCards();
|
||||
}
|
||||
if(stop == 2)
|
||||
DuelEndProc();
|
||||
}
|
||||
@@ -3050,7 +3053,9 @@ void TagDuel::FlushDeckLists() {
|
||||
}
|
||||
// YGOL tag partner cards: STOC_TAG_PARTNER_CARDS 0x5F = uint8_t side + the ygol_query_tag_cards bytes, to that side's two
|
||||
// seats (never the other team) and, when spectators see all, to every observer: after start_duel, after every
|
||||
// MSG_TAG_SWAP, in a seat's field resync (its side) and in an observer's resync / late-watcher snapshot (both sides).
|
||||
// MSG_TAG_SWAP, after any engine batch that changed the side's bytes (TICKET-424), in a seat's field resync (its side)
|
||||
// and in an observer's resync / late-watcher snapshot (both sides). A broadcast records the bytes it sent; a send to
|
||||
// one player (a resync) does not, so it never hides a change the others have not had.
|
||||
void TagDuel::SendTagPartnerCards(int side, DuelPlayer* dp) {
|
||||
if(!pduel)
|
||||
return;
|
||||
@@ -3063,6 +3068,8 @@ void TagDuel::SendTagPartnerCards(int side, DuelPlayer* dp) {
|
||||
NetServer::SendBufferToPlayer(dp, STOC_TAG_PARTNER_CARDS, buf, 1 + len);
|
||||
return;
|
||||
}
|
||||
tag_cards_sent[side].assign(buf + 1, buf + 1 + len);
|
||||
tag_cards_known[side] = true;
|
||||
for(int seat = side * 2; seat < side * 2 + 2; ++seat)
|
||||
if(players[seat])
|
||||
NetServer::SendBufferToPlayer(players[seat], STOC_TAG_PARTNER_CARDS, buf, 1 + len);
|
||||
@@ -3070,6 +3077,20 @@ void TagDuel::SendTagPartnerCards(int side, DuelPlayer* dp) {
|
||||
for(auto oit = observers.begin(); oit != observers.end(); ++oit)
|
||||
NetServer::SendBufferToPlayer(*oit, STOC_TAG_PARTNER_CARDS, buf, 1 + len);
|
||||
}
|
||||
void TagDuel::FlushTagPartnerCards() {
|
||||
if(!pduel)
|
||||
return;
|
||||
unsigned char buf[1 + 6 + (2 * UINT8_MAX + MAINC_MAX) * sizeof(uint32_t)];
|
||||
for(int side = 0; side < 2; ++side) {
|
||||
const int len = ygol_query_tag_cards(pduel, (uint8_t)side, buf);
|
||||
if(len <= 0)
|
||||
continue;
|
||||
if(tag_cards_known[side] && tag_cards_sent[side].size() == (size_t)len
|
||||
&& std::equal(tag_cards_sent[side].begin(), tag_cards_sent[side].end(), buf))
|
||||
continue;
|
||||
SendTagPartnerCards(side);
|
||||
}
|
||||
}
|
||||
void TagDuel::TimeConfirm(DuelPlayer* dp) {
|
||||
if(host_info.time_limit == 0)
|
||||
return;
|
||||
|
||||
@@ -100,6 +100,9 @@ protected:
|
||||
CTOS_Profile profile[4]{};
|
||||
std::vector<uint16_t> preview_attackers; // YGOL attack preview: location << 8 | sequence of every attacker the open battle prompt lists
|
||||
void SendTagPartnerCards(int side, DuelPlayer* dp = nullptr); // YGOL tag partner cards: STOC 0x5F to the side's two seats (+ every observer when they see all), or to dp alone
|
||||
void FlushTagPartnerCards(); // YGOL tag partner cards: after every engine batch, a side whose bytes changed since its last broadcast sends again (TICKET-424)
|
||||
std::vector<unsigned char> tag_cards_sent[2];
|
||||
bool tag_cards_known[2]{};
|
||||
// YGOL coin toss
|
||||
void BeginChoose(int chooser, uint8_t face);
|
||||
int choose_seat{};
|
||||
|
||||
Reference in new issue
Block a user