Native Ranked extension
=======================

Upstream: https://github.com/iw4x/iw4x-client
Pinned revision: d1b175da1a25d31043246de103a702b206269e5a
License: GPLv3; see LICENSE and the upstream dependency license files.
Do not distribute the DLL without its corresponding source/build information.

Build on Windows with Visual Studio 2022 C++ tools and a Windows 10/11 SDK:

  git clone --recursive https://github.com/iw4x/iw4x-client
  git -C iw4x-client checkout d1b175da1a25d31043246de103a702b206269e5a
  git -C iw4x-client submodule update --init --recursive
  python client_native/apply.py iw4x-client

Before generating the game solution, build the statically linked voice libraries:

  python iw4x-client/deps/zeal-voice/fetch_dependencies.py
  cmake -S iw4x-client/deps/zeal-voice -B iw4x-client/deps/zeal-voice/build -G "Visual Studio 17 2022" -A Win32
  cmake --build iw4x-client/deps/zeal-voice/build --config Release --parallel
  ctest --test-dir iw4x-client/deps/zeal-voice/build -C Release --output-on-failure

Then, from iw4x-client:

  tools\premake5.exe vs2022
  MSBuild build\iw4x.sln /m /p:Configuration=Release /p:Platform=Win32

Release/Win32 is the packaged configuration. The premake voice dependency links
the CMake Release libraries; Debug needs matching Debug paths/runtime libraries.
No separate Opus or SRTP runtime DLL is required.

The patch also adds RankedMenus.hpp, which adapts the installed stock party
and search menus, and RankedShortcut.hpp and a narrow controller-dispatch hook
for RB + RT. It consumes the chord only during a server-confirmed Ranked
warmup; ordinary controller input in other modes is unchanged. F6 and the
ranked_warmup console command use the same reversible view toggle.

RankedClasses.hpp restricts the installed class editor while Ranked is active,
and hides previews for the disabled inventory slots. The five base custom
classes remain selectable for new accounts in Ranked, without changing XP. The generated script-only
ranked_class_rules menu normalizes saved custom classes; it adds no visible
lobby panel. RankedBranding.hpp supplies the main-menu PNG materials using
d3dx9_43.dll, already required by the installer. Missing artwork does not block
startup. Artwork creation is confined to the disconnected frontend. It also
loads the Obsidian rank atlas and neutral placement badge for the party menu.
The renderer extracts alpha-preserving sprite regions and decodes them to at
most 256 pixels for clean small-scale rendering. Rank/counter text comes from
the lobby service's authenticated private rating lookup, not local game stats
or menu opens. Unknown/unavailable profiles have no numerical placement count.
The Menus.cpp integration restores each patched item's original fields before
the engine menu loader copies or frees it. Shared restriction expressions and
labels belong to the DLL; allowing menu cleanup to free them caused a crash
when loading the match's class menu. apply.py installs both ownership hooks.
Connected Ranked sessions guard vid_restart with a stock message box. The
IW4x renderer reload can discard frontend game-type data even when UI zones
are pinned; applying video changes from the disconnected frontend remains
supported. This guard retains the party and queue instead of entering that
unsupported reload path. The original command runs outside connected Ranked.

Copy build/bin/Win32/Release/iw4x.dll to client_native/iw4x.dll before building
the installer. This build was made with MSVC 14.44 and SDK 10.0.26100.
The test VM has Build Tools at G:\BuildTools and the checkout at
G:\qa-build\iw4x-client. Its minimal SDK installation avoids the small C: disk.

apply.py adds the Ranked component, extends the existing getInfo response path,
and registers a friend-invite UI callback. It refuses a different upstream
revision. Ranked.cpp contains the native frontend, HTTP lobby requests and
GSC methods for authenticated token binding and installed-map checks.
The public IWD contains only server endpoints and join settings. Private server
tokens live outside game/player packages. The rk_session userinfo dvar is an
ephemeral client-owned token, not a server/API administrative secret.

Use the same patched DLL on the x86 dedicated server and client. Start
 iw4x.exe
rather than the updater/MM launcher. The repository scripts require the new
native GSC functions; an unpatched server cannot load Ranked correctly.
Windows installer 1.32 routes the IW4x/MM executable names through a shared
Zeal launcher and starts the matching x86 game as zeal-game.exe. This preserves
existing shortcuts while avoiding a stock x64 client that cannot load this
extension. The source-only manual install still starts the matching iw4x.exe
directly. Windows is native; Linux runs this Windows binary through Wine.
No native Linux executable or x64 MM binary compatibility is claimed.

Ranked voice integration, 2026-10-12
----------------------------------
RankedVoice.cpp registers local settings and drives HTTPS session negotiation on
its own thread. voice/ contains WASAPI, Opus, libSRTP, adaptive receive timing,
optional RNNoise and tests. The backend routes party/team media from verified
server presence. Voice activation is the default. The stock party menu opens
VOICE SETTINGS; F7 opens it in-game. Scoreboard mute uses the same player IDs.

LegacyVoiceCapture.hpp pauses Miles' imported WinMM capture calls while Ranked
owns voice; leaving Ranked restores ordinary voice. Voice.cpp retains bounds,
stale-frame and lifecycle fixes for ordinary servers. Both paths expose count-
only diagnostics (zv_stats and voice_stats); they never log conversation audio.

See ../docs/VOICE.txt for ports, TLS, settings, deployment and rollback. Exact
runtime evidence and remaining listening/device checks are in
../docs/qa/voice-windows-20261012/REPORT.txt. Preserve voice/THIRD-PARTY-NOTICES.txt
and the corresponding native source with distributed binaries.

RankedMenus.hpp clones menu_xboxlive/menu_xboxlive_lobby from installed assets,
retaining the stock layout, styles and class/callsign/barracks actions. Its
roster feeders show the authenticated Ranked party/queue. The native patch
pins the three already loaded frontend UI fastfiles during the connection,
allowing the stock
class editor and lobby materials to work over connected warmup. Map assets
still unload normally; original UI unload flags return when disconnecting.
