3 Commits
Author SHA1 Message Date
donnyandClaude Opus 5.5 313d8f34de changelog: v1.7.0 (TICKET-451)
Release / linux (push) Successful in 1m55s
Release / windows (push) Successful in 38s
Release / android (push) Successful in 1m13s
Release / release (push) Successful in 7s
Release / attach-windows (push) Successful in 2s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:19:32 -07:00
donnyandClaude Opus 5.5 954fbfc65b prompt context: announce kind byte, record 23 bytes, STOC 0x44 24 bytes (TICKET-451, v1.7.0)
u8 announce_kind after chain_link, set only while MSG_ANNOUNCE_NUMBER is
open: 1 when the script called Duel.AnnounceLevel (it passes playerid +
0x10000 to the unit), else 2 when the asking effect has CATEGORY_DICE and is
visible to the answering player, else 0. Contract, changelog, binding
PromptContext.AnnounceKind + AnnouncePlain / Level / Dice, codec 24 bytes,
probe: plain 0, AnnounceLevel 1, a dice effect's AnnounceNumber 2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 16:46:05 -07:00
donnyandClaude Opus 5.5 3f84b0b50b core: prompt context phase 4, the core asks whether to use an effect (TICKET-451, v1.7.0)
The core's own "use this effect?" prompts carry the asked effect in their
PROCESSOR_SELECT_EFFECTYN / SELECT_YESNO unit (optional trigger, lone quick
trigger 221, activation 94, replacements 218 / 219 / 220, Scrap Chimera), and
the unit pushes it on core.ygol_running as phase 4 while the prompt is open.
Contract row, changelog, binding PromptContext.PhaseAsk, probe check: an
optional End Phase trigger is asked with that card, index 2, phase 4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 16:11:14 -07:00
13 changed files with 131 additions and 58 deletions

No files matched your search

+5 -5
View File
@@ -5,16 +5,16 @@ 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`).
## Unreleased (v1.7.0)
## v1.7.0 — 2026-11-08
Prompt context (proposal 55): right before every prompt the answering seat learns which card and which effect asks.
One export, one message, capability `0x8000`, protocol 12: exports 336 / 857 / 851, capabilities `0xF7FF`.
One export, one message, capability `0x8000`, protocol 12: exports 336 / 857 / 851, capabilities `0xF7FF`. Record 23 bytes, message 24 bytes.
| Date | Change | Ticket | Contract part |
|---|---|---|---|
| 2026-11-08 | Core: `ygol_query_prompt_context(pduel, playerid, out)` (22 bytes: version, has effect, code, controller, location, sequence, position, u64 description, u16 effect index, phase, chain link). `field::execute_cost` / `execute_target` / `execute_operation` push the running effect (handler, description, index, phase 1 / 2 / 3, chain link) on `core.ygol_running` at step 0 and pop it when the function finishes; the innermost one answers. `effect::ygol_script_index`: `card::add_effect` stamps `initial_effect.size()` while the card loads (`STATUS_INITIALIZING`), `0xFFFF` otherwise. A handler the asking player does not control and that is not face-up answers code 0, index `0xFFFF`, description 0. | TICKET-451 | (a) new export |
| 2026-11-08 | Server: `STOC_PROMPT_CONTEXT` `0x44` = those 22 bytes + the prompt's `MSG_*` id, to the answering seat (Tag: `cur_player`) right before every relayed prompt but rock-paper-scissors, only when its capability has the bit; never observers, recorders or replays. `FEATURE_PROMPT_CONTEXT` `0x8000` advertised by Single and Tag rooms, protocol 11 -> 12; no room refuses a joiner without it. Export gates 335 / 856 / 850 -> 336 / 857 / 851. | TICKET-451 | Wire: message `0x44`, capability bit `0x8000`, protocol 12 |
| 2026-11-08 | Binding: `StocMessage.PromptContext`, `FeatureFlags.PromptContext` (in `All`), the `PromptContext` record + `StocCodecs.PromptContext`, `EngineApi.ygol_query_prompt_context`, `Capability.ProtocolVersion` 12. Probe: the prompt context rooms (Single, a second Single duel whose opponent lacks the bit, Tag): a card asks in its cost, target and operation, then hides itself in the Deck and asks both players. | TICKET-451 | (e) C# binding |
| 2026-11-08 | Core: `ygol_query_prompt_context(pduel, playerid, out)` (23 bytes: version, has effect, code, controller, location, sequence, position, u64 description, u16 effect index, phase, chain link, announce kind: 1 `Duel.AnnounceLevel`, 2 a visible `CATEGORY_DICE` effect, on `MSG_ANNOUNCE_NUMBER` only). `field::execute_cost` / `execute_target` / `execute_operation` push the running effect (handler, description, index, phase 1 / 2 / 3, chain link) on `core.ygol_running` at step 0 and pop it when the function finishes; the innermost one answers. The core's own "use this effect?" asks (optional trigger, lone quick trigger desc 221, desc 94, replacements 218 / 219 / 220, Scrap Chimera) carry the asked effect in their `PROCESSOR_SELECT_EFFECTYN` / `SELECT_YESNO` unit and push it as phase 4 (ask) while the prompt is open. `effect::ygol_script_index`: `card::add_effect` stamps `initial_effect.size()` while the card loads (`STATUS_INITIALIZING`), `0xFFFF` otherwise. A handler the asking player does not control and that is not face-up answers code 0, index `0xFFFF`, description 0. | TICKET-451 | (a) new export |
| 2026-11-08 | Server: `STOC_PROMPT_CONTEXT` `0x44` = those 23 bytes + the prompt's `MSG_*` id (24 bytes), to the answering seat (Tag: `cur_player`) right before every relayed prompt but rock-paper-scissors, only when its capability has the bit; never observers, recorders or replays. `FEATURE_PROMPT_CONTEXT` `0x8000` advertised by Single and Tag rooms, protocol 11 -> 12; no room refuses a joiner without it. Export gates 335 / 856 / 850 -> 336 / 857 / 851. | TICKET-451 | Wire: message `0x44`, capability bit `0x8000`, protocol 12 |
| 2026-11-08 | Binding: `StocMessage.PromptContext`, `FeatureFlags.PromptContext` (in `All`), the `PromptContext` record + `StocCodecs.PromptContext`, `EngineApi.ygol_query_prompt_context`, `Capability.ProtocolVersion` 12. Probe: the prompt context rooms (Single, a second Single duel whose opponent lacks the bit, Tag): a card asks in its cost, target and operation, a Fusion's material procedure asks inside that operation and the outer context comes back, the Fusion's optional End Phase trigger is asked with phase 4, announces say kind 0 / 1 / 2, then the card hides itself in the Deck and asks both players; a second duel with another deck order has the same indexes. | TICKET-451 | (e) C# binding |
## v1.6.0 — 2026-11-02
@@ -287,26 +287,28 @@ namespace YGOLegacy.Protocol.Tests
}
[Test]
public void PromptContext_Id_Flag_Protocol_AndRoundTrip_ArePinned_0x44_0x8000_12_23()
public void PromptContext_Id_Flag_Protocol_AndRoundTrip_ArePinned_0x44_0x8000_12_24()
{
Assert.That((int)StocCodecs.PromptContext.Id, Is.EqualTo(0x44));
Assert.That((int)StocMessage.PromptContext, Is.EqualTo(0x44));
Assert.That(FeatureFlags.PromptContext, Is.EqualTo(0x8000));
Assert.That(FeatureFlags.All & FeatureFlags.PromptContext, Is.EqualTo(FeatureFlags.PromptContext));
Assert.That(Capability.ProtocolVersion, Is.EqualTo(12));
Assert.That(PromptContextCodec.Size, Is.EqualTo(23));
Assert.That(PromptContextCodec.Size, Is.EqualTo(24));
Assert.That(new[] { PromptContext.AnnouncePlain, PromptContext.AnnounceLevel, PromptContext.AnnounceDice }, Is.EqualTo(new byte[] { 0, 1, 2 }));
Assert.That(new[] { PromptContext.PhaseOther, PromptContext.PhaseCost, PromptContext.PhaseTarget, PromptContext.PhaseOperation, PromptContext.PhaseAsk }, Is.EqualTo(new byte[] { 0, 1, 2, 3, 4 }));
const ulong description = 12960005233ul;
var payload = new PromptContext(true, 16178681u, 1, 0x04, 2, 0x1, description, 3, PromptContext.PhaseOperation, 2, 13);
var payload = new PromptContext(true, 16178681u, 1, 0x04, 2, 0x1, description, 3, PromptContext.PhaseOperation, 2, PromptContext.AnnounceDice, 143);
var bytes = Bytes(w => StocCodecs.PromptContext.Write(w, payload));
Assert.That(bytes.Length, Is.EqualTo(23));
Assert.That(bytes.Length, Is.EqualTo(24));
Assert.That(bytes[0], Is.EqualTo(1));
Assert.That(bytes[1], Is.EqualTo(1));
Assert.That(BitConverter.ToUInt32(bytes, 2), Is.EqualTo(16178681u));
Assert.That(bytes.Skip(6).Take(4).ToArray(), Is.EqualTo(new byte[] { 1, 0x04, 2, 0x1 }));
Assert.That(BitConverter.ToUInt64(bytes, 10), Is.EqualTo(description));
Assert.That(BitConverter.ToUInt16(bytes, 18), Is.EqualTo(3));
Assert.That(bytes.Skip(20).ToArray(), Is.EqualTo(new byte[] { 3, 2, 13 }));
Assert.That(bytes.Skip(20).ToArray(), Is.EqualTo(new byte[] { 3, 2, 2, 143 }));
var read = StocCodecs.PromptContext.Read(Reader(bytes));
Assert.That(read.Version, Is.EqualTo(1));
@@ -321,15 +323,16 @@ namespace YGOLegacy.Protocol.Tests
Assert.That(read.EffectIndex, Is.EqualTo(3));
Assert.That(read.Phase, Is.EqualTo(PromptContext.PhaseOperation));
Assert.That(read.ChainLink, Is.EqualTo(2));
Assert.That(read.Prompt, Is.EqualTo(13));
Assert.That(read.AnnounceKind, Is.EqualTo(PromptContext.AnnounceDice));
Assert.That(read.Prompt, Is.EqualTo(143));
var none = Bytes(w => StocCodecs.PromptContext.Write(w, PromptContext.None(10)));
Assert.That(none, Is.EqualTo(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 10 }));
Assert.That(none, Is.EqualTo(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 10 }));
Assert.That(StocCodecs.PromptContext.Read(Reader(none)).HasEffect, Is.False);
var hidden = StocCodecs.PromptContext.Read(Reader(Bytes(w => StocCodecs.PromptContext.Write(w, new PromptContext(true, 0, 1, 0x02, 0, 0x8, 0, PromptContext.UnknownIndex, PromptContext.PhaseCost, 1, 13)))));
var hidden = StocCodecs.PromptContext.Read(Reader(Bytes(w => StocCodecs.PromptContext.Write(w, new PromptContext(true, 0, 1, 0x02, 0, 0x8, 0, PromptContext.UnknownIndex, PromptContext.PhaseCost, 1, PromptContext.AnnouncePlain, 13)))));
Assert.That(hidden.IsHidden, Is.True);
Assert.That(hidden.EffectIndex, Is.EqualTo(PromptContext.UnknownIndex));
Assert.Throws<EndOfStreamException>(() => StocCodecs.PromptContext.Read(Reader(bytes.Take(22).ToArray())));
Assert.Throws<EndOfStreamException>(() => StocCodecs.PromptContext.Read(Reader(bytes.Take(23).ToArray())));
}
[Test]
@@ -214,10 +214,10 @@ namespace YGOLegacy.Protocol.Codecs
}
}
// The 22-byte ygol_query_prompt_context record (version, has effect, uint32 code, controller, location, sequence, position, uint64 description, uint16 effect index, phase, chain link) + the prompt's MSG id; no sender stamp (v1.7.0, TICKET-451).
// The 23-byte ygol_query_prompt_context record (version, has effect, uint32 code, controller, location, sequence, position, uint64 description, uint16 effect index, phase, chain link, announce kind) + the prompt's MSG id; no sender stamp (v1.7.0, TICKET-451).
public sealed class PromptContextCodec : IStocCodec<PromptContext>
{
public const int Size = 23;
public const int Size = 24;
public StocMessage Id => StocMessage.PromptContext;
@@ -235,8 +235,9 @@ namespace YGOLegacy.Protocol.Codecs
var effectIndex = reader.ReadUInt16();
var phase = reader.ReadByte();
var chainLink = reader.ReadByte();
var announceKind = reader.ReadByte();
var prompt = reader.ReadByte();
return new PromptContext(version, hasEffect, code, controller, location, sequence, position, description, effectIndex, phase, chainLink, prompt);
return new PromptContext(version, hasEffect, code, controller, location, sequence, position, description, effectIndex, phase, chainLink, announceKind, prompt);
}
public void Write(BinaryWriter writer, PromptContext payload)
@@ -252,6 +253,7 @@ namespace YGOLegacy.Protocol.Codecs
writer.Write(payload.EffectIndex);
writer.Write(payload.Phase);
writer.Write(payload.ChainLink);
writer.Write(payload.AnnounceKind);
writer.Write(payload.Prompt);
}
}
@@ -597,6 +597,10 @@ namespace YGOLegacy.Protocol.Contracts
public const byte PhaseCost = 1;
public const byte PhaseTarget = 2;
public const byte PhaseOperation = 3;
public const byte PhaseAsk = 4;
public const byte AnnouncePlain = 0;
public const byte AnnounceLevel = 1;
public const byte AnnounceDice = 2;
public byte Version { get; }
// False: no effect function runs (battle and idle commands, a plain summon); every other value is zero and EffectIndex is UnknownIndex.
@@ -611,16 +615,19 @@ namespace YGOLegacy.Protocol.Contracts
public ulong Description { get; }
// The order the card's script registered the effect (the same in every duel); UnknownIndex for an effect the script did not register at load.
public ushort EffectIndex { get; }
// PhaseCost, PhaseTarget, PhaseOperation: that function of the effect runs; PhaseAsk: the core asks whether to use the effect.
public byte Phase { get; }
// The chain link the effect is, 0 when it is not on the chain.
public byte ChainLink { get; }
// MSG_ANNOUNCE_NUMBER only: AnnounceLevel (the script called Duel.AnnounceLevel), AnnounceDice (the asking effect is a visible dice effect); AnnouncePlain everywhere else.
public byte AnnounceKind { get; }
// The MSG_* id of the prompt this context belongs to.
public byte Prompt { get; }
public PromptContext(bool hasEffect, uint code, byte controller, byte location, byte sequence, byte position, ulong description, ushort effectIndex, byte phase, byte chainLink, byte prompt)
: this(CurrentVersion, hasEffect, code, controller, location, sequence, position, description, effectIndex, phase, chainLink, prompt) { }
public PromptContext(bool hasEffect, uint code, byte controller, byte location, byte sequence, byte position, ulong description, ushort effectIndex, byte phase, byte chainLink, byte announceKind, byte prompt)
: this(CurrentVersion, hasEffect, code, controller, location, sequence, position, description, effectIndex, phase, chainLink, announceKind, prompt) { }
public PromptContext(byte version, bool hasEffect, uint code, byte controller, byte location, byte sequence, byte position, ulong description, ushort effectIndex, byte phase, byte chainLink, byte prompt)
public PromptContext(byte version, bool hasEffect, uint code, byte controller, byte location, byte sequence, byte position, ulong description, ushort effectIndex, byte phase, byte chainLink, byte announceKind, byte prompt)
{
Version = version;
HasEffect = hasEffect;
@@ -633,10 +640,11 @@ namespace YGOLegacy.Protocol.Contracts
EffectIndex = effectIndex;
Phase = phase;
ChainLink = chainLink;
AnnounceKind = announceKind;
Prompt = prompt;
}
public static PromptContext None(byte prompt) => new PromptContext(false, 0, 0, 0, 0, 0, 0, UnknownIndex, PhaseOther, 0, prompt);
public static PromptContext None(byte prompt) => new PromptContext(false, 0, 0, 0, 0, 0, 0, UnknownIndex, PhaseOther, 0, AnnouncePlain, prompt);
public bool IsHidden => HasEffect && Code == 0;
}
+3 -3
View File
@@ -111,7 +111,7 @@ The host string is space-separated tokens, in this order (`server/gframe/gframe.
| `default_script_reader` | `byte* default_script_reader(const char* script_name, int* len)` | Upstream |
| `ygol_preview_attack` | `int32_t ygol_preview_attack(intptr_t pduel, uint8_t playerid, uint8_t location, uint8_t sequence, uint8_t target_location, uint8_t target_sequence, uint8_t* out)` | Patch 0022 (TICKET-374) + 0024 (TICKET-379), 2026-10-13. A read-only dry run of the damage step. Returns 1 answered, 0 refused (bad pointer, no such card, attacker not a face-up monster on `playerid`'s field, target not a monster on the other field); a refusal writes nothing. `target_location` `0xFF` = direct. `out` is 24 bytes: version (1), flags (bit 0 direct, bit 1 unknown, bit 2 attacker destroyed, bit 3 target destroyed, bit 4 pierce, bit 5 illegal), 2 pad bytes, then five `int32`: attacker value, target value, damage to player 0, damage to player 1, reserved 0. A face-down target answers unknown with every number 0. A pair the battle menu (`field::get_attack_target`) would not offer answers illegal alone with every number 0. Call it only while the engine is parked on a prompt; the duel is byte-identical afterwards. |
| `ygol_query_tag_cards` | `int32_t ygol_query_tag_cards(intptr_t pduel, uint8_t playerid, uint8_t* out)` | v1.2.0 (TICKET-405), 2026-10-15. The waiting tag partner's cards of `playerid`'s side, read only. Returns the byte length written, 0 refused (bad pointer, bad player, not a tag duel); a refusal writes nothing. `out`: `u8 version` (1), `u8 hand_count`, `u8 extra_count`, `u8 pad` (0), `u16 deck_count`, then `u32 hand[hand_count]`, `u32 extra[extra_count]` (bit 31 = face-up, as in `MSG_TAG_SWAP`), `u32 deck[deck_count]` sorted ascending (the order stays secret). At most 7 + 4 x (255 + 255 + 250) bytes in practice; size the buffer for your deck limits. The duel is byte-identical afterwards. |
| `ygol_query_prompt_context` | `int32_t ygol_query_prompt_context(intptr_t pduel, uint8_t playerid, uint8_t* out)` | v1.7.0 (TICKET-451), 2026-11-08. Which effect asks the prompt the engine is parked on, read only; `playerid` is the answering player. Returns 22 (the bytes written), 0 refused (bad pointer, bad player); a refusal writes nothing. `out` (22 bytes, little-endian): `u8 version` (1), `u8 has_effect`, `u32 code` (the handler's `get_code()` now), `u8 controller`, `u8 location`, `u8 sequence`, `u8 position` (the handler now), `u64 description` (the effect's, 0 when none), `u16 effect_index`, `u8 phase` (1 cost, 2 target, 3 operation), `u8 chain_link` (the newest chain link whose effect it is, 0 when none). The effect is the innermost cost / target / operation function running (`field::execute_cost` / `execute_target` / `execute_operation`, the core's only coroutine calls, tracked in `core.ygol_running`); none running (battle and idle commands, chain prompts, a Summon without an effect) = `has_effect` 0, every other byte 0 and `effect_index` `0xFFFF`. **`effect_index`** is the order the card's script registered the effect while the card loaded (`card::add_effect` under `STATUS_INITIALIZING` stamps `initial_effect.size()`): the same in every duel and on every machine for that card's script; an effect registered at any other time (a clone, a copy, a grant, an effect made during the duel) is `0xFFFF`. **Hidden**: when the handler is not controlled by `playerid` and is not face-up (`is_position(POS_FACEUP)`: a face-down card, the other player's hand, Deck or face-down Extra Deck), `code` is 0, `effect_index` `0xFFFF` and `description` 0; the other fields stay. The duel is byte-identical afterwards. |
| `ygol_query_prompt_context` | `int32_t ygol_query_prompt_context(intptr_t pduel, uint8_t playerid, uint8_t* out)` | v1.7.0 (TICKET-451), 2026-11-08. Which effect asks the prompt the engine is parked on, read only; `playerid` is the answering player. Returns 23 (the bytes written), 0 refused (bad pointer, bad player); a refusal writes nothing. `out` (23 bytes, little-endian): `u8 version` (1), `u8 has_effect`, `u32 code` (the handler's `get_code()` now), `u8 controller`, `u8 location`, `u8 sequence`, `u8 position` (the handler now), `u64 description` (the effect's, 0 when none), `u16 effect_index`, `u8 phase` (1 cost, 2 target, 3 operation, 4 ask), `u8 chain_link` (the newest chain link whose effect it is, 0 when none), `u8 announce_kind` (only while a `MSG_ANNOUNCE_NUMBER` is open: 1 the script called `Duel.AnnounceLevel`, which passes `playerid + 0x10000` to the unit; else 2 when the asking effect has `CATEGORY_DICE` and is visible to `playerid`; else 0; always 0 for any other prompt). The effect is the innermost frame on `core.ygol_running`: a cost / target / operation function running (`field::execute_cost` / `execute_target` / `execute_operation`, the core's only coroutine calls; phases 1 / 2 / 3), or an effect the core itself asks about (phase 4, "ask"): the frame lives while that `MSG_SELECT_EFFECTYN` / `MSG_SELECT_YESNO` is open, at the optional trigger (`processor.cpp`, desc 0), the lone quick trigger (desc 221), the cost-time activation ask (desc 94), the three replacement asks (`operations.cpp`, desc 218 / 220 / 219) and Scrap Chimera's material ask (its own description). Other prompts the core builds itself either list several effects (`MSG_SELECT_CHAIN`, `IDLECMD`, `BATTLECMD`, the `SELECT_OPTION` among replacement effects or activation ways) or ask about no effect (attack, desc 31; the Pendulum / Spell-zone redirect, desc 97; Tribute and material prompts): they push nothing and show whatever runs around them. None running (battle and idle commands, chain prompts, a Summon without an effect) = `has_effect` 0, every other byte 0 but `announce_kind`, and `effect_index` `0xFFFF`. **`effect_index`** is the order the card's script registered the effect while the card loaded (`card::add_effect` under `STATUS_INITIALIZING` stamps `initial_effect.size()`): the same in every duel and on every machine for that card's script; an effect registered at any other time (a clone, a copy, a grant, an effect made during the duel) is `0xFFFF`. **Hidden**: when the handler is not controlled by `playerid` and is not face-up (`is_position(POS_FACEUP)`: a face-down card, the other player's hand, Deck or face-down Extra Deck), `code` is 0, `effect_index` `0xFFFF` and `description` 0; the other fields stay. The duel is byte-identical afterwards. |
| `get_registry_value` | `int32_t get_registry_value(intptr_t pduel, const char* key, byte* out_buf)` | Upstream (koishi) |
| `set_registry_value` | `void set_registry_value(intptr_t pduel, const char* key, const char* value)` | Upstream (koishi). The server writes every setup pair here before `special.lua` (patch 0009). |
| `get_registry_keys` | `int32_t get_registry_keys(intptr_t pduel, byte* out_buf)` | Upstream (koishi) |
@@ -207,7 +207,7 @@ duelist's own side (v1.2.0), both sides for an observer when spectators see all
| `0x41` | `STOC_APPEARANCE` | `u16 sender` + `CTOS_Appearance` (354) | Yes | Everyone; stored per seat, replayed to joiners, dropped when the seat empties or moves to the watchers | `0x1` | 1 | 0006 |
| `0x42` | `STOC_DIALOGUE` | `u16 sender` + `CTOS_Dialogue` (206) | Yes | Everyone | `0x2` | 1 | 0006 |
| `0x43` | `STOC_SETUP_PAIRS` | `u16 0xFF`, `u16 count`, then per pair `u16 length` + `key=value` bytes (no terminator) | Yes (`0xFF`) | Every joiner, in the snapshot | `0x4` | 1 | 0009 |
| `0x44` | `STOC_PROMPT_CONTEXT` | The 22 `ygol_query_prompt_context` bytes (section (a)) + `u8 prompt` (the `MSG_*` id of the prompt it belongs to); 23 bytes | No | The seat that answers the prompt (Tag: the team's current hand), and only when its `CTOS_CAPABILITY` had `0x8000`; the packet right before that prompt's `STOC_GAME_MSG`. Sent before every prompt the server relays but `MSG_ROCK_PAPER_SCISSORS`: `MSG_SELECT_BATTLECMD`, `IDLECMD`, `EFFECTYN`, `YESNO`, `OPTION`, `CARD`, `TRIBUTE`, `UNSELECT_CARD`, `CHAIN`, `PLACE`, `DISFIELD`, `POSITION`, `COUNTER`, `SUM`, `MSG_SORT_CARD`, `MSG_ANNOUNCE_RACE`, `ATTRIB`, `CARD`, `NUMBER`. A prompt with no effect running gets `has_effect` 0, so a client never keeps a stale context. Never to observers, the waiting Tag partner or the server-mode recorders, never in a replay; a `MSG_RETRY` re-ask gets none (the context still stands) | `0x8000` | 12 | v1.7.0 |
| `0x44` | `STOC_PROMPT_CONTEXT` | The 23 `ygol_query_prompt_context` bytes (section (a)) + `u8 prompt` (the `MSG_*` id of the prompt it belongs to); 24 bytes | No | The seat that answers the prompt (Tag: the team's current hand), and only when its `CTOS_CAPABILITY` had `0x8000`; the packet right before that prompt's `STOC_GAME_MSG`. Sent before every prompt the server relays but `MSG_ROCK_PAPER_SCISSORS`: `MSG_SELECT_BATTLECMD`, `IDLECMD`, `EFFECTYN`, `YESNO`, `OPTION`, `CARD`, `TRIBUTE`, `UNSELECT_CARD`, `CHAIN`, `PLACE`, `DISFIELD`, `POSITION`, `COUNTER`, `SUM`, `MSG_SORT_CARD`, `MSG_ANNOUNCE_RACE`, `ATTRIB`, `CARD`, `NUMBER`. A prompt with no effect running gets `has_effect` 0, so a client never keeps a stale context. Never to observers, the waiting Tag partner or the server-mode recorders, never in a replay; a `MSG_RETRY` re-ask gets none (the context still stands) | `0x8000` | 12 | v1.7.0 |
| `0x50` | `STOC_SEAT_PLAN` | `u16 0xFF` + `STOC_SeatPlan` (23): `u8 restart_id[16]`, `u16 revision`, `u8 seat_count`, `u8 kind[4]` (25 total; no token on the wire) | Yes (`0xFF`) | Everyone after a plan, swap or move; joiners in the snapshot | `0x8` | 2 | 0011 |
| `0x54` | `STOC_ROOM_RESTARTING` | `u16 0xFF` + `STOC_RoomRestarting` (38): `u8 phase` (1 Prepare, 2 Commit, 3 Abort), `u8 restart_id[16]`, `u8 seat`, `u8 token[16]`, `u32 timeout_ms` | Yes (`0xFF`) | Each participant, with ITS OWN seat and token only | `0x10` | 2 | 0012 |
| `0x56` | `STOC_RESTART_STATUS` | `u16 0xFF` + `STOC_RestartStatus` (21): `u8 phase`, `u8 restart_id[16]`, `u8 acked`, `u8 expected`, `u8 complete`, `u8 reason` (0 none, 1 incompatible, 2 ack timeout, 3 not lobby, 4 not host, 5 busy, 6 bad request) | Yes (`0xFF`) | The host only | `0x10` | 2 | 0012 |
@@ -458,7 +458,7 @@ Namespaces:
| Namespace | What |
|---|---|
| `YGOLegacy.Protocol.{Contracts, Codecs, Framing, Routing}` | Section (b) in C#: the message ids and payload records, the CTOS / STOC codecs, the frame codec and the STOC router. Unchanged from the Unity repo (TICKET-397); v1.2.0 adds `StocMessage.TagPartnerCards`, `FeatureFlags.TagPartnerCards`, the `TagPartnerCards` record and `StocCodecs.TagPartnerCards`, and `Capability.ProtocolVersion` is 9; v1.4.0 adds `ReplayFlags` (`SetupPairs` = `0x40000000`, `SideLp` = `0x20000000`); v1.5.0 adds `FeatureFlags.TagTwoFields` (`0x1000`, in `All`) and `Capability.ProtocolVersion` is 10; v1.6.0 adds `FeatureFlags.TagSharedExtra` (`0x4000`, in `All`) and `Capability.ProtocolVersion` is 11; v1.7.0 adds `StocMessage.PromptContext` (`0x44`), `FeatureFlags.PromptContext` (`0x8000`, in `All`), the `PromptContext` record (`HasEffect`, `Code`, `Controller`, `Location`, `Sequence`, `Position`, `Description`, `EffectIndex`, `Phase`, `ChainLink`, `Prompt`, `IsHidden`, `None(prompt)`, `UnknownIndex` `0xFFFF`, `PhaseCost` / `PhaseTarget` / `PhaseOperation` 1 / 2 / 3) and `StocCodecs.PromptContext` (`PromptContextCodec`, 23 bytes), and `Capability.ProtocolVersion` is 12. |
| `YGOLegacy.Protocol.{Contracts, Codecs, Framing, Routing}` | Section (b) in C#: the message ids and payload records, the CTOS / STOC codecs, the frame codec and the STOC router. Unchanged from the Unity repo (TICKET-397); v1.2.0 adds `StocMessage.TagPartnerCards`, `FeatureFlags.TagPartnerCards`, the `TagPartnerCards` record and `StocCodecs.TagPartnerCards`, and `Capability.ProtocolVersion` is 9; v1.4.0 adds `ReplayFlags` (`SetupPairs` = `0x40000000`, `SideLp` = `0x20000000`); v1.5.0 adds `FeatureFlags.TagTwoFields` (`0x1000`, in `All`) and `Capability.ProtocolVersion` is 10; v1.6.0 adds `FeatureFlags.TagSharedExtra` (`0x4000`, in `All`) and `Capability.ProtocolVersion` is 11; v1.7.0 adds `StocMessage.PromptContext` (`0x44`), `FeatureFlags.PromptContext` (`0x8000`, in `All`), the `PromptContext` record (`HasEffect`, `Code`, `Controller`, `Location`, `Sequence`, `Position`, `Description`, `EffectIndex`, `Phase`, `ChainLink`, `AnnounceKind`, `Prompt`, `IsHidden`, `None(prompt)`, `UnknownIndex` `0xFFFF`, `PhaseCost` / `PhaseTarget` / `PhaseOperation` / `PhaseAsk` 1 / 2 / 3 / 4, `AnnouncePlain` / `AnnounceLevel` / `AnnounceDice` 0 / 1 / 2) and `StocCodecs.PromptContext` (`PromptContextCodec`, 24 bytes), and `Capability.ProtocolVersion` is 12. |
| `YGOLegacy.Engine` | The four types below (TICKET-398). |
| Type | What |
+5 -4
View File
@@ -91,12 +91,13 @@ OCGCORE_API int32_t ygol_preview_attack(intptr_t pduel, uint8_t playerid, uint8_
OCGCORE_API int32_t ygol_query_tag_cards(intptr_t pduel, uint8_t playerid, uint8_t* out);
// [YGOL] v1.7.0 (prompt context, TICKET-451): which effect asks the prompt the engine is parked on, read only.
// playerid = the answering player. out (22 bytes): version (1), has_effect, uint32 code (the handler's current
// playerid = the answering player. out (23 bytes): version (1), has_effect, uint32 code (the handler's current
// code), controller, location, sequence, position, uint64 description, uint16 effect_index (the order the
// card's script registered the effect in initial_effect; 0xffff unknown), phase (1 cost, 2 target, 3 operation),
// chain link (0 none). has_effect 0 = no effect function runs: every other byte 0, effect_index 0xffff. A
// card's script registered the effect in initial_effect; 0xffff unknown), phase (1 cost, 2 target, 3 operation, 4 the core asks whether to use the effect),
// chain link (0 none), announce kind (MSG_ANNOUNCE_NUMBER only: 1 Duel.AnnounceLevel, 2 the effect has
// CATEGORY_DICE and is visible, else 0). has_effect 0 = no effect runs: every other byte 0 but announce kind, effect_index 0xffff. A
// handler playerid does not control and that is not face-up writes code 0, effect_index 0xffff, description 0.
// Returns 22, 0 refused (bad pointer, bad player); a refusal writes nothing.
// Returns 23, 0 refused (bad pointer, bad player); a refusal writes nothing.
OCGCORE_API int32_t ygol_query_prompt_context(intptr_t pduel, uint8_t playerid, uint8_t* out);
// koishi specific
+47 -12
View File
@@ -178,10 +178,12 @@
# that never run, then an Activate that asks a yes/no in its cost, an option in its target and a yes/no in its
# operation, runs a Fusion Monster's material procedure (which asks) inside that operation and asks again, shuffles
# itself into the deck and asks the opponent, then its controller. Every prompt a seat with
# 0x8000 gets comes right after one 23-byte PROMPT_CONTEXT (0x44) naming that prompt: idle, chain and battle
# 0x8000 gets comes right after one 24-byte PROMPT_CONTEXT (0x44) naming that prompt: idle, chain and battle
# prompts say no effect; cost / target / operation say Probe Ask, phase 1 / 2 / 3, effect index 2, its
# description, chain link 1; the nested procedure names the Fusion (index 1, chain link 0) and the operation's
# next prompt names Probe Ask again; the opponent's yes/no names the card in the deck as hidden (code 0, index 0xFFFF,
# next prompt names Probe Ask again; an announce says kind 0 (plain), 1 (Duel.AnnounceLevel) or 2 (a dice effect);
# the Fusion's optional End Phase trigger is asked with phase 4 (ask), index 2;
# the opponent's yes/no names the card in the deck as hidden (code 0, index 0xFFFF,
# description 0) while its controller's next one still names it. A watcher with 0x8000, a seat without it and
# the waiting Tag partners get none; a second duel with another deck order reports the same indexes.
#
@@ -3632,6 +3634,7 @@ NAMES.update({0x44: "PROMPT_CONTEXT"})
PROBE_ASK = PROBE_CARD + 1000
PROBE_ASK_FUSION = PROBE_CARD + 1001
LOCATION_DECK = 0x01
MSG_ANNOUNCE_NUMBER = 143
PROMPT_MSGS = {10, 11, 12, 13, 14, 15, 16, 18, 19, 20, 22, 23, 24, 25, 26, 140, 141, 142, 143}
ASK_LUA = """--Probe Ask (TICKET-451): two effects that never run, then an Activate that asks in its cost, target and operation,
--runs Probe Ask Fusion's material procedure (which asks too) and asks again, shuffles itself into the deck and asks
@@ -3649,6 +3652,7 @@ function s.initial_effect(c)
c:RegisterEffect(e1)
local e2=Effect.CreateEffect(c)
e2:SetDescription(id*16+1)
e2:SetCategory(CATEGORY_DICE)
e2:SetType(EFFECT_TYPE_ACTIVATE)
e2:SetCode(EVENT_FREE_CHAIN)
e2:SetCost(s.cost)
@@ -3670,6 +3674,8 @@ function s.activate(e,tp,eg,ep,ev,re,r,rp)
local fc=Duel.GetFirstMatchingCard(Card.IsCode,tp,LOCATION_EXTRA,0,nil,id+1)
if fc then Duel.SelectFusionMaterial(tp,fc,Duel.GetFieldGroup(tp,LOCATION_HAND,0)) end
Duel.SelectYesNo(tp,id*16+8)
Duel.AnnounceLevel(tp,1,12)
Duel.AnnounceNumber(tp,1,2,3,4,5,6)
c:CancelToGrave()
Duel.SendtoDeck(c,nil,0,REASON_EFFECT)
Duel.SelectYesNo(1-tp,id*16+6)
@@ -3678,7 +3684,8 @@ end
"""
ASK_DESCRIPTION = PROBE_ASK * 16 + 1
ASK_INDEX = 2
ASK_FUSION_LUA = """--Probe Ask Fusion (TICKET-451): a Fusion Monster whose material procedure (its second effect) asks a yes/no.
ASK_FUSION_LUA = """--Probe Ask Fusion (TICKET-451): a Fusion Monster whose material procedure (its second effect) asks a yes/no, and
--whose third effect is an optional trigger from the Extra Deck in its controller's End Phase (the core asks "use it?").
local s,id,o=GetID()
function s.initial_effect(c)
local e0=Effect.CreateEffect(c)
@@ -3695,23 +3702,39 @@ function s.initial_effect(c)
e1:SetCondition(s.fcon)
e1:SetOperation(s.fop)
c:RegisterEffect(e1)
local e2=Effect.CreateEffect(c)
e2:SetDescription(id*16+3)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_PHASE+PHASE_END)
e2:SetRange(LOCATION_EXTRA)
e2:SetCountLimit(1)
e2:SetCondition(s.econ)
e2:SetOperation(s.eop)
c:RegisterEffect(e2)
end
function s.econ(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetTurnPlayer()==tp
end
function s.eop(e,tp,eg,ep,ev,re,r,rp)
end
function s.fcon(e,g,gc,chkf)
return true
end
function s.fop(e,tp,eg,ep,ev,re,r,rp,gc,chkf)
Duel.SelectYesNo(tp,id*16+2)
Duel.AnnounceNumber(tp,7,8)
Duel.SetFusionMaterial(Group.CreateGroup())
end
"""
ASK_FUSION_INDEX = 1
ASK_TRIGGER_INDEX = 2
def prompt_context(d):
# 22-byte record + the prompt's MSG id: version, has effect, u32 code, controller, location, sequence, position,
# u64 description, u16 effect index, phase, chain link, prompt
keys = ("version", "has", "code", "controller", "location", "sequence", "position", "description", "index", "phase", "chain", "prompt")
return dict(zip(keys, struct.unpack("<BBIBBBBQHBBB", d)))
# 23-byte record + the prompt's MSG id: version, has effect, u32 code, controller, location, sequence, position,
# u64 description, u16 effect index, phase, chain link, announce kind, prompt
keys = ("version", "has", "code", "controller", "location", "sequence", "position", "description", "index", "phase", "chain", "announce", "prompt")
return dict(zip(keys, struct.unpack("<BBIBBBBQHBBBB", d)))
def prompts_with_context(c):
@@ -3720,7 +3743,7 @@ def prompts_with_context(c):
for i, (p, d) in enumerate(c.log):
if p == 0x01 and d and d[0] in PROMPT_MSGS:
prev = c.log[i - 1] if i else (None, b"")
ctx = prompt_context(prev[1]) if prev[0] == STOC_PROMPT_CONTEXT and len(prev[1]) == 23 else None
ctx = prompt_context(prev[1]) if prev[0] == STOC_PROMPT_CONTEXT and len(prev[1]) == 24 else None
out.append((d[0], d, ctx))
return out
@@ -3731,7 +3754,7 @@ def contexts_of(c):
def is_none_context(ctx, prompt):
return ctx == {"version": 1, "has": 0, "code": 0, "controller": 0, "location": 0, "sequence": 0, "position": 0,
"description": 0, "index": 0xFFFF, "phase": 0, "chain": 0, "prompt": prompt}
"description": 0, "index": 0xFFFF, "phase": 0, "chain": 0, "announce": 0, "prompt": prompt}
def prompt_context_room(dll_path, port, label, mode, opponent_bit=True, fusion_first=False):
@@ -3824,7 +3847,7 @@ def prompt_context_room(dll_path, port, label, mode, opponent_bit=True, fusion_f
answer(c, first_free_zone(d))
elif t in (MSG_SELECT_EFFECTYN, MSG_SELECT_YESNO):
answer(c, struct.pack("<i", 1))
elif t == MSG_SELECT_OPTION:
elif t in (MSG_SELECT_OPTION, MSG_ANNOUNCE_NUMBER):
answer(c, struct.pack("<i", 0))
if state["done"]:
return True
@@ -3844,7 +3867,7 @@ def prompt_context_room(dll_path, port, label, mode, opponent_bit=True, fusion_f
check(not contexts_of(c), "%s: %s advertised no 0x8000 and got no PROMPT_CONTEXT (%d)" % (label, c.name, len(contexts_of(c))))
continue
missing = [hex(t) for t, _, ctx in got if ctx is None or ctx["prompt"] != t]
check(not missing, "%s: %s: each of its %d prompts came right after a 23-byte PROMPT_CONTEXT naming that prompt (missing: %s)" % (label, c.name, len(got), missing))
check(not missing, "%s: %s: each of its %d prompts came right after a 24-byte PROMPT_CONTEXT naming that prompt (missing: %s)" % (label, c.name, len(got), missing))
check(len(contexts_of(c)) == len(got), "%s: %s: one PROMPT_CONTEXT per prompt, none on its own (%d contexts, %d prompts)" % (label, c.name, len(contexts_of(c)), len(got)))
check(not contexts_of(w), "%s: the watcher advertised 0x8000 and got no PROMPT_CONTEXT (%d)" % (label, len(contexts_of(w))))
@@ -3872,6 +3895,18 @@ def prompt_context_room(dll_path, port, label, mode, opponent_bit=True, fusion_f
check(last["location"] == LOCATION_DECK and last["index"] == ASK_INDEX and last["description"] == ASK_DESCRIPTION,
"%s: after it shuffled itself into the deck its controller still sees it: code, index 2, description, location Deck (%s)" % (label, last))
seen["index"] = [ctx["index"] for ctx in asks]
optional = [ctx for t, d, ctx in mine if t == MSG_SELECT_EFFECTYN]
check(len(optional) == 1 and optional[0]["has"] == 1 and optional[0]["code"] == PROBE_ASK_FUSION and optional[0]["controller"] == player
and optional[0]["location"] == LOCATION_EXTRA and optional[0]["index"] == ASK_TRIGGER_INDEX and optional[0]["description"] == PROBE_ASK_FUSION * 16 + 3
and optional[0]["phase"] == 4 and optional[0]["chain"] == 0,
"%s: the End Phase \"use this effect?\" for the optional trigger names Probe Ask Fusion in the Extra Deck, effect index 2, its description, phase 4 (ask), chain link 0 (%s)" % (label, optional))
if optional:
seen["index"] = seen.get("index", []) + [optional[0]["index"]]
announces = [(ctx["code"], ctx["phase"], ctx["announce"]) for t, d, ctx in mine if t == MSG_ANNOUNCE_NUMBER]
check(announces == [(PROBE_ASK_FUSION, 3, 0), (PROBE_ASK, 3, 1), (PROBE_ASK, 3, 2)],
"%s: announce kind: the Fusion's plain Duel.AnnounceNumber says 0, Probe Ask's Duel.AnnounceLevel 1 (level wins over dice), its dice effect's Duel.AnnounceNumber 2 (%s)" % (label, announces))
others = [ctx["announce"] for c in seated for t, d, ctx in prompts_with_context(c) if ctx and t != MSG_ANNOUNCE_NUMBER]
check(others and not any(others), "%s: every other prompt's context has announce kind 0 (%d prompts)" % (label, len(others)))
opponent = [c for c in seated if c is not a and any(t == MSG_SELECT_YESNO for t, _, _ in prompts_with_context(c))]
check(len(opponent) == 1, "%s: exactly one other seat answered the operation's yes/no (%s)" % (label, [c.name for c in opponent]))
if opponent and opponent[0] not in bitless:
@@ -3910,7 +3945,7 @@ def prompt_context_suite(dll_path, port):
first = prompt_context_room(dll_path, port, "single", 0)
second = prompt_context_room(dll_path, port + 1, "single, second duel, other deck order, opponent without 0x8000", 0, opponent_bit=False, fusion_first=True)
prompt_context_room(dll_path, port + 2, "tag", 2)
expected = [ASK_INDEX] * 3 + [ASK_FUSION_INDEX] + [ASK_INDEX] * 2
expected = [ASK_INDEX] * 3 + [ASK_FUSION_INDEX] + [ASK_INDEX] * 2 + [ASK_TRIGGER_INDEX]
check(first.get("index") == second.get("index") == expected,
"the effect indexes are the same in two duels with a different deck order and seed: %s and %s" % (first.get("index"), second.get("index")))
+9
View File
@@ -349,6 +349,7 @@ struct processor {
uint16_t script_index{ 0xffff };
uint8_t phase{ 0 };
uint8_t chain_link{ 0 };
uint64_t category{ 0 };
};
std::vector<ygol_running_effect> ygol_running;
uint8_t shuffle_check_disabled{ FALSE };
@@ -873,4 +874,12 @@ public:
//#define PROCESSOR_SWAP_CONTROL_S 145
//#define PROCESSOR_MOVETOFIELD_S 161
// [YGOL] v1.7.0 prompt context (processor.cpp): phases 1 cost, 2 target, 3 operation, 4 the core asks whether to use the effect
constexpr uint8_t YGOL_PHASE_COST = 1;
constexpr uint8_t YGOL_PHASE_TARGET = 2;
constexpr uint8_t YGOL_PHASE_OPERATION = 3;
constexpr uint8_t YGOL_PHASE_ASK = 4;
void ygol_push_running(field* pfield, effect* peffect, uint8_t phase);
void ygol_pop_running(field* pfield);
#endif /* FIELD_H_ */
+5
View File
@@ -492,6 +492,9 @@ OCGCORE_API int32_t ygol_query_prompt_context(intptr_t pduel, uint8_t playerid,
card* handler = running.empty() ? nullptr : running.back().handler;
if(handler && !pd->cards.count(handler))
handler = nullptr;
const auto& units = pd->game_field->core.units;
const bool announce = !units.empty() && units.front().type == PROCESSOR_ANNOUNCE_NUMBER;
const bool announce_level = announce && (units.front().arg1 >> 16) == 1; // Duel.AnnounceLevel passes playerid + 0x10000
byte* ptr = out;
buffer_write<uint8_t>(ptr, 1);
if(!handler) {
@@ -505,6 +508,7 @@ OCGCORE_API int32_t ygol_query_prompt_context(intptr_t pduel, uint8_t playerid,
buffer_write<uint16_t>(ptr, 0xffff);
buffer_write<uint8_t>(ptr, 0);
buffer_write<uint8_t>(ptr, 0);
buffer_write<uint8_t>(ptr, announce_level ? 1 : 0);
return (int32_t)(ptr - out);
}
const auto& top = running.back();
@@ -519,6 +523,7 @@ OCGCORE_API int32_t ygol_query_prompt_context(intptr_t pduel, uint8_t playerid,
buffer_write<uint16_t>(ptr, visible ? top.script_index : 0xffff);
buffer_write<uint8_t>(ptr, top.phase);
buffer_write<uint8_t>(ptr, top.chain_link);
buffer_write<uint8_t>(ptr, announce_level ? 1 : (announce && visible && (top.category & CATEGORY_DICE)) ? 2 : 0);
return (int32_t)(ptr - out);
}
OCGCORE_API int32_t get_registry_value(intptr_t pduel, const char* key, byte* out_buf) {
+5 -4
View File
@@ -88,12 +88,13 @@ OCGCORE_API int32_t ygol_preview_attack(intptr_t pduel, uint8_t playerid, uint8_
OCGCORE_API int32_t ygol_query_tag_cards(intptr_t pduel, uint8_t playerid, uint8_t* out);
// [YGOL] v1.7.0 (prompt context, TICKET-451): which effect asks the prompt the engine is parked on, read only.
// playerid = the answering player. out (22 bytes): version (1), has_effect, uint32 code (the handler's current
// playerid = the answering player. out (23 bytes): version (1), has_effect, uint32 code (the handler's current
// code), controller, location, sequence, position, uint64 description, uint16 effect_index (the order the
// card's script registered the effect in initial_effect; 0xffff unknown), phase (1 cost, 2 target, 3 operation),
// chain link (0 none). has_effect 0 = no effect function runs: every other byte 0, effect_index 0xffff. A
// card's script registered the effect in initial_effect; 0xffff unknown), phase (1 cost, 2 target, 3 operation, 4 the core asks whether to use the effect),
// chain link (0 none), announce kind (MSG_ANNOUNCE_NUMBER only: 1 Duel.AnnounceLevel, 2 the effect has
// CATEGORY_DICE and is visible, else 0). has_effect 0 = no effect runs: every other byte 0 but announce kind, effect_index 0xffff. A
// handler playerid does not control and that is not face-up writes code 0, effect_index 0xffff, description 0.
// Returns 22, 0 refused (bad pointer, bad player); a refusal writes nothing.
// Returns 23, 0 refused (bad pointer, bad player); a refusal writes nothing.
OCGCORE_API int32_t ygol_query_prompt_context(intptr_t pduel, uint8_t playerid, uint8_t* out);
// koishi specific
+4 -4
View File
@@ -665,7 +665,7 @@ int32_t field::pay_lp_cost(uint32_t step, uint8_t playerid, uint32_t cost, uint3
if(core.select_options.size() == 1)
returns.ivalue[0] = 0;
else if(core.select_effects[0] == 0 && core.select_effects.size() == 2)
add_process(PROCESSOR_SELECT_EFFECTYN, 0, 0, (group*)core.select_effects[1]->handler, playerid, 218);
add_process(PROCESSOR_SELECT_EFFECTYN, 0, core.select_effects[1], (group*)core.select_effects[1]->handler, playerid, 218); // [YGOL] v1.7.0 prompt context
else
add_process(PROCESSOR_SELECT_OPTION, 0, 0, 0, playerid, 0);
return FALSE;
@@ -729,7 +729,7 @@ int32_t field::remove_counter(uint16_t step, uint32_t reason, card* pcard, uint8
if(core.select_options.size() == 1)
returns.ivalue[0] = 0;
else if(core.select_effects[0] == nullptr && core.select_effects.size() == 2)
add_process(PROCESSOR_SELECT_EFFECTYN, 0, 0, (group*)core.select_effects[1]->handler, rplayer, 220);
add_process(PROCESSOR_SELECT_EFFECTYN, 0, core.select_effects[1], (group*)core.select_effects[1]->handler, rplayer, 220); // [YGOL] v1.7.0 prompt context
else
add_process(PROCESSOR_SELECT_OPTION, 0, 0, 0, rplayer, 0);
return FALSE;
@@ -825,7 +825,7 @@ int32_t field::remove_overlay_card(uint16_t step, uint32_t reason, card* pcard,
if(core.select_options.size() == 1)
returns.ivalue[0] = 0;
else if(core.select_effects[0] == 0 && core.select_effects.size() == 2)
add_process(PROCESSOR_SELECT_EFFECTYN, 0, 0, (group*)core.select_effects[1]->handler, rplayer, 219);
add_process(PROCESSOR_SELECT_EFFECTYN, 0, core.select_effects[1], (group*)core.select_effects[1]->handler, rplayer, 219); // [YGOL] v1.7.0 prompt context
else
add_process(PROCESSOR_SELECT_OPTION, 0, 0, 0, rplayer, 0);
return FALSE;
@@ -5629,7 +5629,7 @@ int32_t field::select_synchro_material(int16_t step, uint8_t playerid, card* pca
}
if(mfiltered && check_with_sum_limit_m(nsyn_filtered, lv, 0, min, max, 0xffff, mcount)) {
if(mremoved && check_with_sum_limit_m(nsyn_removed, lv, 0, min, max, 0xffff, mcount)) {
add_process(PROCESSOR_SELECT_YESNO, 0, 0, 0, playerid, peffect->description);
add_process(PROCESSOR_SELECT_YESNO, 0, peffect, 0, playerid, peffect->description); // [YGOL] v1.7.0 prompt context
core.units.begin()->step = 9;
return FALSE;
} else
+17 -8
View File
@@ -84,7 +84,11 @@ uint32_t field::process() {
}
}
case PROCESSOR_SELECT_EFFECTYN: {
if (it->step == 0 && it->peffect)
ygol_push_running(this, it->peffect, YGOL_PHASE_ASK); // [YGOL] v1.7.0 prompt context: the core asks whether to use this effect
if (select_effect_yes_no(it->step, it->arg1, it->arg2, (card*)it->ptarget)) {
if (it->peffect)
ygol_pop_running(this);
core.units.pop_front();
return pduel->buffer_size();
} else {
@@ -93,7 +97,11 @@ uint32_t field::process() {
}
}
case PROCESSOR_SELECT_YESNO: {
if (it->step == 0 && it->peffect)
ygol_push_running(this, it->peffect, YGOL_PHASE_ASK); // [YGOL] v1.7.0 prompt context
if (select_yes_no(it->step, it->arg1, it->arg2)) {
if (it->peffect)
ygol_pop_running(this);
core.units.pop_front();
return pduel->buffer_size();
} else {
@@ -728,7 +736,7 @@ uint32_t field::process() {
#pragma warning(pop)
#endif
// [YGOL] v1.7.0 prompt context: remember which effect function runs, so ygol_query_prompt_context can name it at a prompt
static void ygol_push_running(field* pfield, effect* peffect, uint8_t phase) {
void ygol_push_running(field* pfield, effect* peffect, uint8_t phase) {
processor::ygol_running_effect running;
running.handler = peffect->get_handler();
if(!running.handler)
@@ -736,6 +744,7 @@ static void ygol_push_running(field* pfield, effect* peffect, uint8_t phase) {
running.description = peffect->description;
running.script_index = peffect->ygol_script_index;
running.phase = phase;
running.category = peffect->category;
auto& chain = pfield->core.current_chain;
for(auto it = chain.rbegin(); it != chain.rend(); ++it) {
if(it->triggering_effect == peffect) {
@@ -745,7 +754,7 @@ static void ygol_push_running(field* pfield, effect* peffect, uint8_t phase) {
}
pfield->core.ygol_running.push_back(running);
}
static void ygol_pop_running(field* pfield) {
void ygol_pop_running(field* pfield) {
if(!pfield->core.ygol_running.empty())
pfield->core.ygol_running.pop_back();
}
@@ -776,7 +785,7 @@ int32_t field::execute_cost(uint16_t step, effect * triggering_effect, uint8_t t
core.units.begin()->arg2 = core.shuffle_check_disabled;
core.shuffle_check_disabled = FALSE;
++core.check_level;
ygol_push_running(this, triggering_effect, 1);
ygol_push_running(this, triggering_effect, YGOL_PHASE_COST);
}
core.reason_effect = triggering_effect;
core.reason_player = triggering_player;
@@ -830,7 +839,7 @@ int32_t field::execute_operation(uint16_t step, effect * triggering_effect, uint
core.units.begin()->arg2 = core.shuffle_check_disabled;
core.shuffle_check_disabled = FALSE;
++core.check_level;
ygol_push_running(this, triggering_effect, 3);
ygol_push_running(this, triggering_effect, YGOL_PHASE_OPERATION);
}
core.reason_effect = triggering_effect;
core.reason_player = triggering_player;
@@ -889,7 +898,7 @@ int32_t field::execute_target(uint16_t step, effect * triggering_effect, uint8_t
core.units.begin()->arg2 = core.shuffle_check_disabled;
core.shuffle_check_disabled = FALSE;
++core.check_level;
ygol_push_running(this, triggering_effect, 2);
ygol_push_running(this, triggering_effect, YGOL_PHASE_TARGET);
}
core.reason_effect = triggering_effect;
core.reason_player = triggering_player;
@@ -1181,7 +1190,7 @@ int32_t field::process_phase_event(int16_t step, int32_t phase) {
else
pduel->write_buffer32(26);
if(tf_count == 0 && to_count == 1 && fc_count == 0 && cn_count == 0) {
add_process(PROCESSOR_SELECT_EFFECTYN, 0, 0, (group*)core.select_chains[0].triggering_effect->get_handler(), check_player, 0);
add_process(PROCESSOR_SELECT_EFFECTYN, 0, core.select_chains[0].triggering_effect, (group*)core.select_chains[0].triggering_effect->get_handler(), check_player, 0); // [YGOL] v1.7.0 prompt context: the asked effect rides in peffect
return FALSE;
} else {
add_process(PROCESSOR_SELECT_CHAIN, 0, 0, 0, check_player, core.spe_effect[check_player]);
@@ -1432,7 +1441,7 @@ int32_t field::process_point_event(int16_t step, int32_t skip_trigger, int32_t s
core.units.begin()->step = 5;
return FALSE;
} else if(core.select_chains.size() == 1 && !core.current_chain.size()) {
add_process(PROCESSOR_SELECT_EFFECTYN, 0, 0, (group*)core.select_chains[0].triggering_effect->get_handler(), core.current_player, 221);
add_process(PROCESSOR_SELECT_EFFECTYN, 0, core.select_chains[0].triggering_effect, (group*)core.select_chains[0].triggering_effect->get_handler(), core.current_player, 221); // [YGOL] v1.7.0 prompt context
return FALSE;
} else {
add_process(PROCESSOR_SELECT_CHAIN, 0, 0, 0, core.current_player, 0x7f);
@@ -4253,7 +4262,7 @@ int32_t field::add_chain(uint16_t step) {
returns.ivalue[0] = TRUE;
return FALSE;
}
add_process(PROCESSOR_SELECT_EFFECTYN, 0, 0, (group*)peffect->get_handler(), playerid, 94);
add_process(PROCESSOR_SELECT_EFFECTYN, 0, peffect, (group*)peffect->get_handler(), playerid, 94); // [YGOL] v1.7.0 prompt context
} else
returns.ivalue[0] = FALSE;
return FALSE;
+2 -2
View File
@@ -476,7 +476,7 @@ constexpr uint32_t FEATURE_TAG_SHARED_EXTRA = 0x4000;
// YGOL prompt context (proposal 55): which card and which effect asks (ygol_query_prompt_context), sent to the answering seat right
// before every relayed prompt but rock-paper-scissors; never to observers, never in a replay; a room does not refuse a joiner without it
constexpr uint32_t FEATURE_PROMPT_CONTEXT = 0x8000;
constexpr int PROMPT_CONTEXT_RECORD_SIZE = 22; // the ygol_query_prompt_context answer; the message adds the prompt's MSG id after it
constexpr int PROMPT_CONTEXT_RECORD_SIZE = 23; // the ygol_query_prompt_context answer; the message adds the prompt's MSG id after it
constexpr uint8_t TAG_PARTNER_CARDS_VERSION = 1;
// the one-use bootstrap secret of a replacement server: a host-string token parsed apart from the ygol.* pairs, never stored anywhere else
extern uint8_t bootstrap_secret[16];
@@ -672,7 +672,7 @@ inline bool IsFeatureMessage(unsigned char pktType) {
#define STOC_APPEARANCE 0x41 // uint16_t + CTOS_Appearance
#define STOC_DIALOGUE 0x42 // uint16_t + CTOS_Dialogue
#define STOC_SETUP_PAIRS 0x43 // uint16_t (0xff) + uint16_t count, then per pair uint16_t length + "key=value"
#define STOC_PROMPT_CONTEXT 0x44 // the 22-byte ygol_query_prompt_context record + uint8_t prompt MSG id, no sender stamp, to the answering seat only (YGOL prompt context)
#define STOC_PROMPT_CONTEXT 0x44 // the 23-byte ygol_query_prompt_context record + uint8_t prompt MSG id, no sender stamp, to the answering seat only (YGOL prompt context)
#define STOC_SEAT_PLAN 0x50 // uint16_t (0xff) + STOC_SeatPlan (YGOL host seats)
// YGOL rules restart: uint16_t (0xff) + the struct
#define STOC_ROOM_RESTARTING 0x54 // STOC_RoomRestarting, to each participant with its own seat and token