From 173df5d8e655d2c79ae8ddad27db3db960e7987c Mon Sep 17 00:00:00 2001 From: donnyjang Date: Wed, 14 Oct 2026 22:38:18 -0700 Subject: [PATCH] server: export ygol_engine_version; the Windows gate is 334 TICKET-388. ygol_engine_version() returns the string the build was given (build/windows.ps1 -Version, env YGOL_ENGINE_VERSION into a define by gframe/premake5.lua), "local" when none; static storage, no allocation. One new export, so the Windows export gate moves 333 -> 334 and the changelog gets its Unreleased row, all in this commit. Verified: build -Version v0.0.1 prints exports: 334 (expected 334); ctypes call prints v0.0.1. Co-Authored-By: Claude Fable 5.1 --- CHANGELOG.md | 1 + build/windows.ps1 | 12 ++++++++---- server/gframe/premake5.lua | 2 ++ server/gframe/serverapi.cpp | 9 +++++++++ server/gframe/serverapi.h | 2 ++ 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a77843..ad7436d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ are the fork patches replayed into this repo as commits (`git log --oneline -- s | Date | Change | Ticket | Contract part | |---|---|---|---| +| 2026-10-14 | `ygol_engine_version()`: returns the version string the build was given (`build/windows.ps1 -Version`), `local` when none. Windows export gate 333 -> 334. | TICKET-388 | C API: 1 export | ## Replayed fork patches (before the first tag) diff --git a/build/windows.ps1 b/build/windows.ps1 index 3c30ff3..688f9eb 100644 --- a/build/windows.ps1 +++ b/build/windows.ps1 @@ -10,16 +10,19 @@ workload and a Windows 10 SDK, and a repo path WITHOUT spaces: libevent's premake emits an unquoted xcopy prebuild step that splits on a space. + -Version is what ygol_engine_version() returns ("local" when not given). + Output: out\win64\ygol-engine.dll (+ .pdb). The export gate is the truth: - the script FAILS unless the DLL exports exactly 333 symbols (start_server, - stop_server, and the core C API re-exported, ygol_sb_* and - ygol_preview_attack included). The Unity repo's old ygoserver.dll had 327: + the script FAILS unless the DLL exports exactly 334 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. #> [CmdletBinding()] param( [string]$Premake = "C:\premake\premake5.exe", - [int]$ExpectedExports = 333 + [string]$Version = "local", + [int]$ExpectedExports = 334 ) $ErrorActionPreference = "Stop" @@ -57,6 +60,7 @@ try { $env:SERVER_PRO3_SUPPORT = "1" $env:LOG_IN_CHAT = "1" $env:USE_SIMD = "best" + $env:YGOL_ENGINE_VERSION = $Version Write-Host "==> premake vs2022" & $Premake vs2022 diff --git a/server/gframe/premake5.lua b/server/gframe/premake5.lua index 07d6de9..e5c4563 100644 --- a/server/gframe/premake5.lua +++ b/server/gframe/premake5.lua @@ -25,6 +25,8 @@ if SERVER_MODE then if SERVER_PRO3_SUPPORT then files { "gframe.h", "serverapi.cpp", "serverapi.h" } defines { "SERVER_PRO3_SUPPORT" } + -- [YGOL] ygol_engine_version() returns this; the build script sets it from -Version + defines { "YGOL_ENGINE_VERSION=" .. (os.getenv("YGOL_ENGINE_VERSION") or "local") } end if SERVER_ZIP_SUPPORT then diff --git a/server/gframe/serverapi.cpp b/server/gframe/serverapi.cpp index 40e0369..13f8823 100644 --- a/server/gframe/serverapi.cpp +++ b/server/gframe/serverapi.cpp @@ -51,4 +51,13 @@ namespace ygo { YGOSERVER_API void stop_server() { NetServer::StopServer(); } +#ifndef YGOL_ENGINE_VERSION +#define YGOL_ENGINE_VERSION local +#endif +#define YGOL_STRINGIZE_(x) #x +#define YGOL_STRINGIZE(x) YGOL_STRINGIZE_(x) + YGOSERVER_API const char* ygol_engine_version() { + static const char version[] = YGOL_STRINGIZE(YGOL_ENGINE_VERSION); + return version; + } } diff --git a/server/gframe/serverapi.h b/server/gframe/serverapi.h index ab21298..f910284 100644 --- a/server/gframe/serverapi.h +++ b/server/gframe/serverapi.h @@ -21,6 +21,8 @@ namespace ygo { YGOSERVER_API int start_server(const char* args); YGOSERVER_API void stop_server(); + // [YGOL] the version the build was given (build/windows.ps1 -Version), "local" when none; static storage, never freed + YGOSERVER_API const char* ygol_engine_version(); } #endif // !SERVERAPI_H