upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/test
diff options
context:
space:
mode:
authorDominik <55330408+Dom-in@users.noreply.github.com>2026-11-22 21:10:40 +0000
committerDominik <55330408+Dom-in@users.noreply.github.com>2026-11-22 21:10:40 +0000
commitf74b8eb87e2bc35a3d31d583d8b261cb5c31c829 (patch)
treea180a60776bdccf42a2832aa2a8a39e73ea348f6 /runtime/test
parente3662721ea213d0b4a2161ee3ada022c3c6bd9dc (diff)
xgameruntime: read LEONIDA_GAME_DIR wide for MicrosoftGame.Config
GetEnvironmentVariableA narrowed a game folder named outside the ANSI code page (e.g. a runic or CJK character on cp1252), so the package locale lookup missed its MicrosoftGame.Config. Read the variable and open the file wide. The test uses U+16A0, which no ANSI code page has (it fails with the narrow read). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/test')
-rw-r--r--runtime/test/xgameruntime_test.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/runtime/test/xgameruntime_test.cpp b/runtime/test/xgameruntime_test.cpp
index fe7942ff0..12c47a157 100644
--- a/runtime/test/xgameruntime_test.cpp
+++ b/runtime/test/xgameruntime_test.cpp
@@ -466,6 +466,26 @@ void check_run_time_load() {
466 DeleteFileA((game + "\\MicrosoftGame.Config").c_str()); 466 DeleteFileA((game + "\\MicrosoftGame.Config").c_str());
467 RemoveDirectoryA(game.c_str()); 467 RemoveDirectoryA(game.c_str());
468 SetEnvironmentVariableA("LEONIDA_GAME_DIR", nullptr); 468 SetEnvironmentVariableA("LEONIDA_GAME_DIR", nullptr);
469 {
470 // A game folder outside every ANSI code page (U+16A0, a runic letter) reaches MicrosoftGame.Config intact.
471 wchar_t wtmp[MAX_PATH] = {};
472 GetTempPathW(MAX_PATH, wtmp);
473 const std::wstring wide = std::wstring(wtmp) + L"leonida_xpackage_\u16a0ocale";
474 CreateDirectoryW(wide.c_str(), nullptr);
475 SetEnvironmentVariableW(L"LEONIDA_GAME_DIR", wide.c_str());
476 const std::wstring wconfig = wide + L"\\MicrosoftGame.Config";
477 if (FILE* f = _wfopen(wconfig.c_str(), L"wb")) {
478 std::fputs("<Game><Resources><Resource Language=\"qq-QQ\"/></Resources></Game>", f);
479 std::fclose(f);
480 }
481 char wlocale[32] = {};
482 check(reinterpret_cast<Locale>(slot(pk, 11))(pk, sizeof(wlocale), wlocale) == S_OK &&
483 std::strcmp(wlocale, "qq-QQ") == 0,
484 "slot 11 reads MicrosoftGame.Config from a game folder named outside the ANSI code page");
485 DeleteFileW(wconfig.c_str());
486 RemoveDirectoryW(wide.c_str());
487 SetEnvironmentVariableW(L"LEONIDA_GAME_DIR", nullptr);
488 }
469 // Slots 23-26 are the named exports' content-package mounts: XPackageMount, the path size and path of the 489 // Slots 23-26 are the named exports' content-package mounts: XPackageMount, the path size and path of the
470 // handle, and closing it. XPackageMountHandle is one u64, passed by value. 490 // handle, and closing it. XPackageMountHandle is one u64, passed by value.
471 using Mount = HRESULT(STDMETHODCALLTYPE*)(void*, const char*, uint64_t*); 491 using Mount = HRESULT(STDMETHODCALLTYPE*)(void*, const char*, uint64_t*);