From 3f84b0b50ba9c19d9ad827edfd22a6d0e1e4093c Mon Sep 17 00:00:00 2001 From: donnyjang Date: Sun, 8 Nov 2026 16:11:14 -0700 Subject: [PATCH] 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 --- CHANGELOG.md | 4 +-- .../FeatureCodecTests.cs | 1 + .../Protocol/Contracts/FeaturePayloads.cs | 2 ++ contract/engine-contract.md | 2 +- contract/ocgapi.h | 2 +- contract/probe-feature-messages.py | 30 +++++++++++++++++-- core/field.h | 8 +++++ core/ocgapi.h | 2 +- core/operations.cpp | 8 ++--- core/processor.cpp | 24 ++++++++++----- 10 files changed, 63 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fbf070..a018630 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,9 +12,9 @@ One export, one message, capability `0x8000`, protocol 12: exports 336 / 857 / 8 | 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 | 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. 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 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 | 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, 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 diff --git a/binding/YGOLegacy.Engine.Tests/FeatureCodecTests.cs b/binding/YGOLegacy.Engine.Tests/FeatureCodecTests.cs index 1f79740..b6c6340 100644 --- a/binding/YGOLegacy.Engine.Tests/FeatureCodecTests.cs +++ b/binding/YGOLegacy.Engine.Tests/FeatureCodecTests.cs @@ -295,6 +295,7 @@ namespace YGOLegacy.Protocol.Tests 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(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); diff --git a/binding/YGOLegacy.Engine/Protocol/Contracts/FeaturePayloads.cs b/binding/YGOLegacy.Engine/Protocol/Contracts/FeaturePayloads.cs index 4e91bbf..0bf9025 100644 --- a/binding/YGOLegacy.Engine/Protocol/Contracts/FeaturePayloads.cs +++ b/binding/YGOLegacy.Engine/Protocol/Contracts/FeaturePayloads.cs @@ -597,6 +597,7 @@ 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 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,6 +612,7 @@ 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; } diff --git a/contract/engine-contract.md b/contract/engine-contract.md index 6b8e73b..634ad36 100644 --- a/contract/engine-contract.md +++ b/contract/engine-contract.md @@ -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 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, 4 ask), `u8 chain_link` (the newest chain link whose effect it is, 0 when none). 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 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) | diff --git a/contract/ocgapi.h b/contract/ocgapi.h index d487a4d..8306fd6 100644 --- a/contract/ocgapi.h +++ b/contract/ocgapi.h @@ -93,7 +93,7 @@ OCGCORE_API int32_t ygol_query_tag_cards(intptr_t pduel, uint8_t playerid, uint8 // [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 // 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), +// 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). has_effect 0 = no effect function runs: every other byte 0, 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. diff --git a/contract/probe-feature-messages.py b/contract/probe-feature-messages.py index fa3b0c8..2b48fa4 100644 --- a/contract/probe-feature-messages.py +++ b/contract/probe-feature-messages.py @@ -181,7 +181,8 @@ # 0x8000 gets comes right after one 23-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; 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. # @@ -3678,7 +3679,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,6 +3697,20 @@ 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 @@ -3705,6 +3721,7 @@ function s.fop(e,tp,eg,ep,ev,re,r,rp,gc,chkf) end """ ASK_FUSION_INDEX = 1 +ASK_TRIGGER_INDEX = 2 def prompt_context(d): @@ -3872,6 +3889,13 @@ 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"]] 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 +3934,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"))) diff --git a/core/field.h b/core/field.h index fb85cea..8de13c4 100644 --- a/core/field.h +++ b/core/field.h @@ -873,4 +873,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_ */ diff --git a/core/ocgapi.h b/core/ocgapi.h index d496450..345ebfa 100644 --- a/core/ocgapi.h +++ b/core/ocgapi.h @@ -90,7 +90,7 @@ OCGCORE_API int32_t ygol_query_tag_cards(intptr_t pduel, uint8_t playerid, uint8 // [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 // 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), +// 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). has_effect 0 = no effect function runs: every other byte 0, 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. diff --git a/core/operations.cpp b/core/operations.cpp index cb1916f..6d0a286 100644 --- a/core/operations.cpp +++ b/core/operations.cpp @@ -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 diff --git a/core/processor.cpp b/core/processor.cpp index 1c804a3..0d465d6 100644 --- a/core/processor.cpp +++ b/core/processor.cpp @@ -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) @@ -745,7 +753,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 +784,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 +838,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 +897,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 +1189,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 +1440,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 +4261,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;