core: ygol_query_prompt_context names the effect that asks a prompt (TICKET-451, v1.7.0)

field::execute_cost / execute_target / execute_operation push the running
effect (handler, description, stable index, phase 1 / 2 / 3, chain link) on
core.ygol_running at step 0 and pop it when the function finishes; the
innermost entry is the effect that asks. effect::ygol_script_index is stamped
in card::add_effect while the card loads (initial_effect.size()), 0xffff
otherwise. The export writes 22 bytes; a handler the asking player does not
control and that is not face-up answers code 0, index 0xffff, description 0.
Export gates 335 / 856 / 850 -> 336 / 857 / 851.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
donnyandClaude Opus 5.5 committed 2026-11-08 16:05:08 -07:00
1 parent 4cd908d7af
commit b6ef8a31bc
10 files changed
+108 -9

No files matched your search

+3 -3
View File
@@ -57,7 +57,7 @@ jobs:
git clean -fdx -e out
if ($LASTEXITCODE -ne 0) { exit 1 }
- name: Build (contract check, export gate 335, engine.json)
- name: Build (contract check, export gate 336, engine.json)
id: build
run: |
$version = "local"
@@ -104,7 +104,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build (contract check, export gate 856, engine.json)
- name: Build (contract check, export gate 857, engine.json)
run: |
version=local
case "$GITHUB_REF" in refs/tags/v*) version="$GITHUB_REF_NAME";; esac
@@ -126,7 +126,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build (contract check, export gate 850, engine.json)
- name: Build (contract check, export gate 851, engine.json)
run: |
version=local
case "$GITHUB_REF" in refs/tags/v*) version="$GITHUB_REF_NAME";; esac
+2 -2
View File
@@ -125,7 +125,7 @@ RUN SERVER_ZIP_SUPPORT=1 SERVER_TAG_SURRENDER_CONFIRM=1 premake5 gmake \
&& make -C build config=release -j"$(nproc)" ygopro \
&& cp bin/release/ygopro /out/ygoserver
RUN file /out/libygol-engine.so /out/ygoserver \
&& export-gate nm /out/libygol-engine.so 856 "$VERSION" /out
&& export-gate nm /out/libygol-engine.so 857 "$VERSION" /out
FROM scratch AS linux
COPY --from=linux-build /out/ /
@@ -140,7 +140,7 @@ RUN YGOL_ENGINE_VERSION=$VERSION premake5 gmake \
&& make -C build config=release_android_arm64 -j"$(nproc)" ygoserver \
&& mkdir -p /out && cp bin/android_arm64/release/libygol-engine.so /out/
RUN file /out/libygol-engine.so \
&& export-gate "$NDK_DIR"/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-nm /out/libygol-engine.so 850 "$VERSION" /out
&& export-gate "$NDK_DIR"/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-nm /out/libygol-engine.so 851 "$VERSION" /out
FROM scratch AS android
COPY --from=android-build /out/ /
+2 -2
View File
@@ -21,7 +21,7 @@
binding is the version of the C# binding released with this engine (the same tag).
Output: out\win64\ygol-engine.dll (+ .pdb). The export gate is the truth:
the script FAILS unless the DLL exports exactly 335 symbols (start_server,
the script FAILS unless the DLL exports exactly 336 symbols (start_server,
stop_server, ygol_engine_version, and the core C API re-exported, ygol_sb_*
and ygol_preview_attack included). The Unity repo's old ygoserver.dll had 327:
its own core copy never carried patch 0008's six ygol_sb_* exports.
@@ -30,7 +30,7 @@
param(
[string]$Premake = "C:\premake\premake5.exe",
[string]$Version = "local",
[int]$ExpectedExports = 335
[int]$ExpectedExports = 336
)
$ErrorActionPreference = "Stop"
+9
View File
@@ -90,6 +90,15 @@ OCGCORE_API int32_t ygol_preview_attack(intptr_t pduel, uint8_t playerid, uint8_
// tag duel); a refusal writes nothing. The duel is byte-identical afterwards (proposal 33 Rule 11).
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
// 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
// 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.
OCGCORE_API int32_t ygol_query_prompt_context(intptr_t pduel, uint8_t playerid, uint8_t* out);
// koishi specific
OCGCORE_API int32_t get_registry_value(intptr_t pduel, const char* key, byte* out_buf);
OCGCORE_API void set_registry_value(intptr_t pduel, const char* key, const char* value);
+6 -2
View File
@@ -1958,10 +1958,14 @@ int32_t card::add_effect(effect* peffect) {
return 0;
peffect->id = pduel->game_field->infos.field_id++;
peffect->card_type = data.type;
if (get_status(STATUS_INITIALIZING))
if (get_status(STATUS_INITIALIZING)) {
peffect->flag[0] |= EFFECT_FLAG_INITIAL;
else if (get_status(STATUS_COPYING_EFFECT))
peffect->ygol_script_index = (uint16_t)initial_effect.size(); // [YGOL] v1.7.0 prompt context: the script's registration order
} else {
peffect->ygol_script_index = 0xffff;
if (get_status(STATUS_COPYING_EFFECT))
peffect->flag[0] |= EFFECT_FLAG_COPY;
}
if (get_status(STATUS_COPYING_EFFECT)) {
peffect->copy_id = pduel->game_field->infos.copy_id;
peffect->reset_flag |= pduel->game_field->core.copy_reset;
+1
View File
@@ -65,6 +65,7 @@ public:
int32_t operation{ 0 };
uint8_t cost_checked{ FALSE };
uint8_t is_granted{ 0 };
uint16_t ygol_script_index{ 0xffff }; // [YGOL] v1.7.0 prompt context: registration order in the card's initial_effect, 0xffff = not from it
effect_set required_handorset_effects;
LuaParamType object_type{ PARAM_TYPE_INT };
+9
View File
@@ -342,6 +342,15 @@ struct processor {
uint8_t selfdes_disabled{ FALSE };
uint8_t overdraw[2]{};
int32_t check_level{ 0 };
// [YGOL] v1.7.0 prompt context: the effect functions running now (cost / target / operation), innermost last
struct ygol_running_effect {
card* handler{ nullptr };
uint32_t description{ 0 };
uint16_t script_index{ 0xffff };
uint8_t phase{ 0 };
uint8_t chain_link{ 0 };
};
std::vector<ygol_running_effect> ygol_running;
uint8_t shuffle_check_disabled{ FALSE };
uint8_t shuffle_hand_check[2]{};
uint8_t shuffle_deck_check[2]{};
+39
View File
@@ -482,6 +482,45 @@ OCGCORE_API int32_t ygol_query_tag_cards(intptr_t pduel, uint8_t playerid, uint8
buffer_write<uint32_t>(ptr, code);
return (int32_t)(ptr - out);
}
// [YGOL] v1.7.0 (prompt context) -- see ocgapi.h. Reads field::core.ygol_running, the cost / target / operation
// functions running now (processor.cpp); the innermost one is the effect that asks.
OCGCORE_API int32_t ygol_query_prompt_context(intptr_t pduel, uint8_t playerid, uint8_t* out) {
duel* pd = (duel*)pduel;
if(!pd || !out || !duel_set.count(pd) || !pd->game_field || !check_playerid(playerid))
return 0;
const auto& running = pd->game_field->core.ygol_running;
card* handler = running.empty() ? nullptr : running.back().handler;
if(handler && !pd->cards.count(handler))
handler = nullptr;
byte* ptr = out;
buffer_write<uint8_t>(ptr, 1);
if(!handler) {
buffer_write<uint8_t>(ptr, 0);
buffer_write<uint32_t>(ptr, 0);
buffer_write<uint8_t>(ptr, 0);
buffer_write<uint8_t>(ptr, 0);
buffer_write<uint8_t>(ptr, 0);
buffer_write<uint8_t>(ptr, 0);
buffer_write<uint64_t>(ptr, 0);
buffer_write<uint16_t>(ptr, 0xffff);
buffer_write<uint8_t>(ptr, 0);
buffer_write<uint8_t>(ptr, 0);
return (int32_t)(ptr - out);
}
const auto& top = running.back();
const bool visible = handler->current.controler == playerid || handler->is_position(POS_FACEUP);
buffer_write<uint8_t>(ptr, 1);
buffer_write<uint32_t>(ptr, visible ? handler->get_code() : 0);
buffer_write<uint8_t>(ptr, handler->current.controler);
buffer_write<uint8_t>(ptr, handler->current.location);
buffer_write<uint8_t>(ptr, handler->current.sequence);
buffer_write<uint8_t>(ptr, handler->current.position);
buffer_write<uint64_t>(ptr, visible ? top.description : 0);
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);
return (int32_t)(ptr - out);
}
OCGCORE_API int32_t get_registry_value(intptr_t pduel, const char* key, byte* out_buf) {
if (!pduel || !key || !out_buf) return -1;
+9
View File
@@ -87,6 +87,15 @@ OCGCORE_API int32_t ygol_preview_attack(intptr_t pduel, uint8_t playerid, uint8_
// tag duel); a refusal writes nothing. The duel is byte-identical afterwards (proposal 33 Rule 11).
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
// 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
// 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.
OCGCORE_API int32_t ygol_query_prompt_context(intptr_t pduel, uint8_t playerid, uint8_t* out);
// koishi specific
OCGCORE_API int32_t get_registry_value(intptr_t pduel, const char* key, byte* out_buf);
OCGCORE_API void set_registry_value(intptr_t pduel, const char* key, const char* value);
+28
View File
@@ -727,6 +727,28 @@ uint32_t field::process() {
#ifdef _MSC_VER
#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) {
processor::ygol_running_effect running;
running.handler = peffect->get_handler();
if(!running.handler)
running.handler = peffect->owner;
running.description = peffect->description;
running.script_index = peffect->ygol_script_index;
running.phase = phase;
auto& chain = pfield->core.current_chain;
for(auto it = chain.rbegin(); it != chain.rend(); ++it) {
if(it->triggering_effect == peffect) {
running.chain_link = it->chain_count;
break;
}
}
pfield->core.ygol_running.push_back(running);
}
static void ygol_pop_running(field* pfield) {
if(!pfield->core.ygol_running.empty())
pfield->core.ygol_running.pop_back();
}
int32_t field::execute_cost(uint16_t step, effect * triggering_effect, uint8_t triggering_player) {
if(!triggering_effect->cost) {
core.solving_event.splice(core.solving_event.begin(), core.sub_solving_event);
@@ -754,6 +776,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);
}
core.reason_effect = triggering_effect;
core.reason_player = triggering_player;
@@ -765,6 +788,7 @@ int32_t field::execute_cost(uint16_t step, effect * triggering_effect, uint8_t t
core.reason_effect = 0;
core.reason_player = PLAYER_NONE;
--core.check_level;
ygol_pop_running(this);
if(core.check_level == 0) {
if(core.shuffle_hand_check[0])
shuffle(0, LOCATION_HAND);
@@ -806,6 +830,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);
}
core.reason_effect = triggering_effect;
core.reason_player = triggering_player;
@@ -817,6 +842,7 @@ int32_t field::execute_operation(uint16_t step, effect * triggering_effect, uint
core.reason_effect = 0;
core.reason_player = PLAYER_NONE;
--core.check_level;
ygol_pop_running(this);
if(core.check_level == 0) {
if(core.shuffle_hand_check[0])
shuffle(0, LOCATION_HAND);
@@ -863,6 +889,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);
}
core.reason_effect = triggering_effect;
core.reason_player = triggering_player;
@@ -874,6 +901,7 @@ int32_t field::execute_target(uint16_t step, effect * triggering_effect, uint8_t
core.reason_effect = 0;
core.reason_player = PLAYER_NONE;
--core.check_level;
ygol_pop_running(this);
if(core.check_level == 0) {
if(core.shuffle_hand_check[0])
shuffle(0, LOCATION_HAND);