Skip to content

Feat/widescreen hud local / Water Animation / FOV - #76

Closed
kr4uzi wants to merge 96 commits into
B2BF:mainfrom
kr4uzi:feat/widescreen-hud-local
Closed

kr4uzi wants to merge 96 commits into
B2BF:mainfrom
kr4uzi:feat/widescreen-hud-local

Conversation

@kr4uzi

@kr4uzi kr4uzi commented Nov 15, 2026

Copy link
Copy Markdown

Fix for #69 (B2FB) and FOV + Widescreen kr4uzi#33

Markus Kraus and others added 30 commits November 3, 2026 18:57
The getter returned a fixed 2 ahead of its own logic, and the console
setter raised every value below 2 to 2 in release builds, so a server
could never start a round with a single player: the client kept showing
"The game will start when 1 more player(s) join" even with
sv.numPlayersNeededToStart 1 and bots on the map.

Retail does neither. The bf2 ELF getter (080BC1F0) returns 6, or 8 from
33 slots up, on ranked servers and the configured value otherwise; the
console SET is a raw field write. Both functions now match that.

Validated on the Windows x86 dedicated server with the retail 1.50
client: with sv.numPlayersNeededToStart 1 the round starts on the first
human spawn and the bots join the round.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Math, Core, IO, Scene, Physics and Platform units the AI library needs, plus the GameLogic/GameEvents AI call
sites (collision-handler and radio-courier reports, CombatArea AI queries, PortalEvent, DropVehicleEvent
producer). Minimal hunks only; Polynom.h keeps its libstdc++ licence notice.

goUpInPath restores the leading slash it strips, as the ELF does; on Windows only when the path had one,
because isPathAbsolute also accepts drive paths there. The Linux plugin loader calls deinitDll before dlclose
so a map reload cannot reuse stale AI singletons ([CHOSEN, not recovered], a native-port design). The
RendDX9 and bf2_runtime_pair manifests link the units the recovered Math code now needs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: OpenAI Codex <noreply@openai.com>
All 10,961 in-scope libaidll.so functions of BF2 1.50, recovered from the ia-32 ELF with amd-64 and PE
cross-checks; evidence vocabulary as in AGENTS.md ([INFERRED], [UNRESOLVED], [PLATFORM], [CHOSEN, not
recovered]). Chosen declarations exist only for never-implemented pure slots and null-only member pointers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: OpenAI Codex <noreply@openai.com>
…rary

One AIDLL source manifest, Code/Build/aidll_sources.txt, feeds both CMake and aidll.cmd. It lists the units
in the retail link order, which is also the static-initialisation order, read from the .ctors table of
libaidll.so. The engine image excludes every AIDLL-only unit by a directory rule (AI/AIDLL minus the shared
CommonSingletonServer, plus three units outside it), so bf2_w32ded.exe never links them. syntaxcheck.cmd
covers every AI unit. The linux-x64 preset builds a native libaidll.so with an export map (AidllAbi); this
native library is a native-port design, not retail. AIDLL test fixtures are updated for the retired stops.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: OpenAI Codex <noreply@openai.com>
The engine's instance (bf2 ds:0x8ABBCB0) was declared under the [CHOSEN] name g_random and defined in
ParticleTemplate.cpp; the AI DLL's (libaidll BSS 0x4DD454) as Rand in Random.cpp. Both retail images name it
dice::hfe::Rand and initialise it in Random.cpp's static init (bf2 0x83CB610, libaidll 0x48A850: iostream
Init, then the default seed). Random.h now declares one extern Random Rand; Random.cpp defines it for each
image; every g_random use is renamed (mechanical, no behaviour change).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: OpenAI Codex <noreply@openai.com>
bf2_runtime_pair (x86 checks): e44067b added the [TEMP] grenade_trace
diagnostic (GrenadeTrace.h), whose log() reads WorldPref::mTickCount from
PointPhysicsNode.cpp. The counter is defined in Core/System.cpp, which the
harness does not link, so link.exe failed with LNK2019. Define the counter
in the harness's existing link-completion scaffolding, next to the other
retail globals it stands in for. No production TU changes, so the x86
retail images are untouched; runtime_pair.cmd needs no source-list change.

bf2_w64ded (x64 strict link): e0fcdaa made VoipServerInternal call the
CBF2VoipServer facade, which the x86 image imports from the
BF2VoipServer_w32ded.dll side image. That DLL target is defined only under
NOT BF2_BUILD_X64 (and its .def pins x86 decorations), so the x64 exe had
no definitions. Link the voice-server module statically into the native
Windows x64 port, as the Linux image already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BGWewitYSRmJLenBNiW8ar
AIDLL_r.dll is a DICE Canada BoosterPack2 debug build of the AI DLL
(2006-05-04, asserts and __FILE__ paths, no PDB). It is older than 1.50 but
already has the 1.50 AI features. It is used as evidence for names, enum
values and source-file placement only; behaviour stays matched to retail 1.50
(libaidll.so / AIDLL.dll). Follows the review notes on B2BF#68.

Names
- WTSticky -> WTC4 (assert "wInfo->getWeaponType() == WTC4", BBC4.cpp).
- Information::isOfType(InformationType), DICE's name (assert
  "!targetPrimaryInfo->isOfType(ITSoldier)"). The single-bit object-type flag
  tests use it with the IT* names (enum-to-string switch 0x100D3010), resolving
  the [UNRESOLVED] flag notes. BotMain::event_airborn tests ITAir, then
  ITHelicopter, as retail compiles it (ELF 0x18D740).
- Kit types documented: 6 is KTAT, 7..12 KTExtended1..6.
- 89 member and parameter renames from AIDLL_r assert expressions, each
  checked by the field offset the assert reads and by its use in the tree
  (BotNavigation, BotMain, SquadManager/Formation, SAI, AIStrategicObject*,
  AISettings, BotManager, QuadTree/ClusterGraph, ...). Evidence addresses are
  in the comments.

Source placement (AIDLL_r __FILE__ paths)
- Moved: Aimer, BotScript.h -> AIBotActionPlan/; UrgencyMerger -> AIBot/;
  AIMineManager -> AIKnowledge/; WeaponInfoManager, CustomCurve -> AIUtils/;
  AerialHeightMap -> AIPathFinding/AerialHeightMap/; UserOrderManager ->
  AIStrategicEntity/UserOrders/; AILandingZoneManager, InformationManager ->
  Main/.
- Split, functions moved unchanged: SensingAgentPatterns into the Soldier,
  Turret, MouseFreeLook and Null pattern TUs; SCurve out of CustomCurve;
  IAIMain, IAIPathfindingSetup and IBotManagerModifier into their own TUs.
- Code/Build/aidll_sources.txt, Code/Tests/syntaxcheck.cmd and the
  Code/Tests/aidll fixtures follow the moves and renames.

No behaviour change intended: where AIDLL_r and the tree were compared, they
agree with 1.50 apart from asserts. Built and smoke-tested on macOS
(bf2_aidll, vtable audit unchanged, 16-bot round); the Windows fixtures were
updated as text only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AI: cross-check against the AIDLL_r debug build (names, TU placement)
…ainst retail)

Recovers the retail Memory.dll (Ver 1.01, 2005/01/10 "Final") into Code/BF2/Memory as its own
image, bf2_memory. Every function cites its PE address; placement follows the shipped function
and data order. The Final build is mostly stubs: only the chunk pools, the sanity limit,
getStatus and the resource counters do work; the counters, trace and histogram exports return
constants, as in retail.

- Platform seams behind #if, [CHOSEN, not recovered]: constructor/destructor instead of DllMain
  on POSIX, stderr instead of the message box, pthreads, and a 16-byte header slot on 64-bit.
- BF2_MEMORY_PASSTHROUGH (AUTO/ON/OFF) forwards to malloc/free under AddressSanitizer.
- Built on request only (EXCLUDE_FROM_ALL) and linked into no game image: the game keeps
  allocating through the shared CRT (issue #7). Code/BF2/Memory is skipped by the engine source
  discovery in CMakeLists.txt and Code/Build/build.cmd.
- Windows: Code/Build/memory.cmd. Tests: Code/Tests/memory (unit tests, internal tests, and
  memory_diff, which runs one allocation script against the retail and the rebuilt DLL; the
  outputs were identical with MSVC x86).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Memory: recover Memory.dll (111/111 functions, differential-tested against retail)
Branch: `mac/pr1-engine` → `main`. First of three stacked PRs: (1) this, (2) `mac/pr2-renderer`, (3) `mac/pr3-macos`.
Diff: 583 files, +23,580 / −3,585. Code and build files only.

Contents
- Engine and game recoveries and fixes in Core, IO, Game, Scene, Sound, Physics, Animation, Math and VoIP. Examples:
  - the scene object lifecycle and ObjectManager queries, recovered against the PE;
  - the GameServer radio messages in self-hosted games;
  - zoom hides the crosshair;
  - the input and window message paths.
- Menu, HUD and client UI: SwiffPlayer natives, gameswf and BFMeme recoveries and fixes.
- AI: updates to the AI library since #1/#2.
- Platform-neutral helpers the later stages build on:
  - scripted input (`Platform/InputScript`);
  - the x87 arithmetic policy (`X87Compat`, `ExtendedFloat` for arm64).
- Shared interfaces from the renderer tree. Engine code here uses three headers from it: `GeomMisc/DebugCircleDrawer.h`, `GeomMisc/DebugLineDrawer.h` and `Geom/ParticleSystem/ParticleSystemManager.h`.
- Tests:
  - `runtime_pair` fixtures for the recovered `Object` manager and destructor contracts (PE 0x0071E3D0, 0x007200D0);
  - POSIX registry, network and thread checks.
- Build files: `CMakeLists.txt`, `CMakePresets.json`, `Code/Build` scripts and `package_release.py`.
  - These are one file each for all three stages, so they already define the renderer and macOS targets.
  - The macOS parts only take effect on macOS (PR 3).

The detailed history of every change, with the PE/ELF evidence, is on `mac-metal`. This PR carries the final state of its files.

Validation (this stage on its own)
- Windows (MSVC 14.44, the CI steps):
  - x86: `build_python.cmd`, configure, `bf2_run_checks` and `bf2_editor_run_checks`, `bf2_w32ded`, `bf2_aidll`.
  - x64: `build_python.cmd`, configure, `bf2_w64ded`.
  - All pass.
- Linux (Ubuntu 26.04, `linux-x64`): `bf2` and `dice_py_check_run` pass.
- Not built at this stage: the Windows client and editor. Their renderer is still `main`'s and needs PR 2; hosted CI skips both anyway (no April 2005 DirectX SDK).

The per-change history with the PE/ELF evidence is on mac-metal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Branch: `mac/pr3-macos` → `mac/pr2-renderer` (stacked; retarget to `main` after PRs 1 and 2 are merged).
Diff: 198 files, +50,796 / −7. Code and build files only. After this PR, `main` equals the validated `mac/metal-client` branch byte for byte.

Contents
- The macOS client (`[CHOSEN, not recovered]`; there was no retail macOS image). A native client for Intel (x86_64) and Apple silicon (arm64), with no Wine and no Windows DLLs.
- `Code/BF2/Platform/Gfx/Metal`: Metal implements the Direct3D 9 / D3DX subset the renderer uses. It covers resources, state, shaders, MSAA, device loss and reset after a fullscreen focus loss, and screenshots.
- `Code/BF2/Platform/Gfx/Effect`: native effect compilation with vkd3d-shader 2.1 and MojoShader, both carrying the repository's patches.
- `Code/BF2/Platform/macOS`: the Cocoa host. It provides the window, fullscreen, focus and input, display modes, the paths, the CPU info and protected data.
- `Code/BF2/IO/Input/Mac*`, `BF2Window_macos.cpp`: input devices and the window on the Cocoa host.
- `tools/macos`: only the files the build runs.
  - The native dependency build (`nativefx/`, `vkd3d-patches/`, `d3dxfx/patches`).
  - The D3D9 forwarding generator check.
  - The static-plugin and AI vtable audits, which `bf2_client` depends on.
- `Code/Tests/macos_*`: the macOS checks (Metal device, forwarding, effects) and the M2 bundle scripts.
- CI. `.github/workflows/build.yml` gains a `macos` job on `macos-14` with one leg each for arm64 and x86_64 (x86_64 is cross-compiled).
  - It fetches the pinned vkd3d (`vkd3d-2.1`, fb7f9ff3) and MojoShader (ad5dff84) sources and builds the native effect libraries.
  - It builds `bf2_client`, `bf2` and `bf2_aidll`, checks the architectures, runs the Python runtime check on arm64, and uploads the client and server packages.
  - `release.yml` attaches the four macOS packages; `package_release.py` already knows them (PR 1).

Not included (stays on `mac-metal`)
- `docs/` (the port's engineer guides, the track logs), `AGENTS.md`, and the test and VM tooling under `tools/`.
- Exceptions the code cites. Recovered code refers to the two owner exceptions in `mac-metal`'s `AGENTS.md`, the unimplemented-slot exception and the unobservable-type exception.
- The M2 bundle tooling. `Code/Tests/macos_c_arm64` (`package.sh`, `run.sh`) needs the loopback harness `tools/macos/loopback`, which stays on `mac-metal`.

Validation (the final tree, identical to `mac/metal-client`)
macOS, Intel (i7-8569U, Iris Plus 655, macOS 15.7):
- CI simulation. The CI steps ran from scratch: the fetch, the native effect build (5.5 min), the `macos-x64` preset build (vtable audit 139/0, all images x86_64), `dice_py_check_run` and packaging.
- Renderer gate: PASS. infantry-range, render-view-dalian and render-view-ocs were all within their view limits, plus a map2 reload, with 0 `[FRONTIER]` and 0 crash reports.
- Final test at High with 4x AA (Dalian, scripted run and gun, 16 bots): Metal runs `samples=4`, 42 fps.

Apple silicon (MacBook Air M2, 8 GB, macOS 26.5), from the arm64 bundle of the same renderer code:
- All arm64 checks pass (Metal device and GPU, vtable runtime checks, Python, AI loader).
- The gate: infantry-range, render-view-dalian, render-view-ocs and map2-reload all pass, with 0 `[FRONTIER]` and 0 crash reports.
- High with 4x AA: `samples=4`, 91 fps.

Windows and Linux on the final tree: the CI steps pass (x86 checks 5/5 and editor checks 926/0, both servers, the AI library, both clients, the editor, and Linux `bf2` with `dice_py_check_run`).

Notes for review
- macOS CI not yet run on GitHub. The macOS job has only been simulated locally (Intel host). Its first real run on the arm64 runner happens with this PR.
- LGPL obligations. The macOS client links vkd3d-shader and the FFmpeg Bink decoders (both LGPL-2.1+) statically. The packages carry the licences; release binaries also carry the LGPL relinking obligations.

The per-change history with the PE/ELF evidence is on mac-metal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Branch: `mac/pr2-renderer` → `mac/pr1-engine` (stacked; retarget to `main` after PR 1 is merged).
Diff: 360 files, +82,923 / −34,311. Code and build files only.

Contents
- RendDX9.dll is fully recovered. The renderer core and Geom, GeomMisc and RendMisc are covered: renderer, video options, effects, shaders, textures, terrain, meshes, lighting and shadows, particles, decals, roads, overgrowth, post-production, fonts, the debug renderers and the console bindings.
  - Counts: 5767 functions recovered (5679 done, 88 `[CHOSEN]` under the unobservable-type exception); 3916 compiler/STL/CRT/SDK library functions; 76 thunks.
  - 3 accepted stops:
    - `Effect::begin`, the retail null-dereference path;
    - `TerrainEditable::runTool` on macOS, an editor-only boundary;
    - the Linux Bink branch of `Video::open`, since there is no Linux client.
  - Evidence: every body cites its PE address. The detailed history with the evidence is on `mac-metal`.
- Video-mode fallback (`[CHOSEN, not recovered]`, kr4uzi/OpenBF2 issue #4). Retail stops on a profile resolution or refresh rate the display does not offer, which kills a fullscreen client without a message. `VideoOptions::setDynamicOption` now selects the closest supported mode instead, using the scoring of the client-side DLL fix in kr4uzi/gamespy-emulator.
- Bink movies through vendored FFmpeg Bink decoders (LGPL-2.1+, `External/ffmpeg-bink`), in black-box agreement with retail `binkw32`. Windows x64 now plays the intro and menu movies; Windows x86 keeps `binkw32.dll`.
- Mesh stripifier: vendored meshoptimizer (MIT).
- The platform-neutral D3D9/D3DX subset (`Platform/Gfx/D3D9Subset.h`, `D3DX9Subset.h`, `Include/`, `D3D9Forward/`). The Windows D3DX fallback (builds without the DirectX SDK) and the optional `BF2_GFX_SEAM` build use it.
- `Code/Build/renddx9.cmd`: the full source list, split for cmd.exe's line limit, plus the x64 Bink sources.

Validation (this stage on its own, on top of PR 1)
- Windows (MSVC 14.44, the CI steps):
  - x86: the checks, `bf2_w32ded`, `bf2_aidll`, `bf2_client`, `bf2_editor`.
  - x64: `bf2_w64ded`, `bf2_client`.
  - All pass.
- Linux (`linux-x64`): `bf2` and `dice_py_check_run` pass.
- Earlier in game, on the same code (Boot Camp VM, retail server on port 16890):
  - x86 and x64 clients spawn and play the scripted run and gun at High with 4x AA;
  - the video-mode fallback works in fullscreen;
  - the x64 client plays EA, dice, legal, intro and the menu movie.

The per-change history with the PE/ELF evidence is on mac-metal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GitHub no longer provides the macos-14 image ("The configuration 'macos-14-arm64-us-default' is not
supported"), so both macOS legs were cancelled before their first step. macos-15 is the current
Apple-silicon image.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The first macos-15 run stopped in vkd3d's configure: "perl module 'JSON' not found". The local
builds had the module already. cpanminus installs it into a local lib that PERL5LIB points at.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ls the job

The step called dxsdk.cmd without `fallback`, so on a hosted runner (no April 2005 SDK) it failed with
exit code 1: the if-errorlevel branch wrote its notice but left the error level set. The step now makes
the same call as renddx9.cmd and textureatlasbuilder.cmd (`dxsdk.cmd x86 fallback`) and always exits 0;
it reports found=false only when neither the SDK nor the D3DX fallback is usable. The x86 client and
editor build with the fallback on hosted runners, as main's workflow already shows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The second macos-15 run stopped in vkd3d's configure: "vulkan.h not found". The local builds take
vulkan-headers, spirv-headers and pkg-config from Homebrew under /usr/local, which the compiler searches
by default; the Apple-silicon runner's /opt/homebrew is not, so CPPFLAGS names both include directories.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Windows matrix built the client only on x86, from before the x64 client existed. The D3DX check
now runs for both architectures (dxsdk.cmd <arch> fallback) and the client step builds bf2_client on
x64 as well: RendDX9 x64 with the Bink port, through the D3DX fallback on hosted runners. The x64
package stays server-only; the editor and the retail layout checks stay x86-only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The aim correction rounds a sub-unit mouse step up to one count with `mx = mx > 0 ? 1 : -1`, an int
assigned to a float, which MSVC x86 reports as C4244. The constants are now 1.0f and -1.0f; the
values are unchanged. This was the only warning the change added over main's x86 build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Engine, game, AI, UI and the fully recovered renderer (1/2)
macOS client with the Metal renderer, macOS CI (2/2)
…scard

- PerformanceLogging (BF2Engine +0x74) is now a complete type (Game/Main/PerformanceLogging.h), so
  shutdownGame and shutdownEngine no longer delete an incomplete type (MSVC C4150, clang
  -Wdelete-incomplete). Linux ELF evidence: vtable 0x08892F60 with the single slot handleEvent (empty
  body, 0x0813AFF0); typeinfo 0x08892FA8 with the single base IEventListener. The vtable is stored only by
  the two inlined destructors (0x08138259, 0x081394DF), and GSPerfLogAtPlayerCount is only registered as
  a default (0x0812F44D), so 1.50 never creates the object. No data members ([CHOSEN, not recovered]:
  nothing constructs or reads one). The client PE is [INFERRED] to match.
- BF2Engine::shutdownEngine: the window (+0x10) and BF2Render (+0x18) deletes are compiled only into
  client images. The dedicated image never creates either object (BF2Engine::init's client branch
  does), so both pointers stay null there; the client-only classes are not declared in a dedicated
  build, which made the deletes incomplete (C4150).
- dwordB0 (+0xB0), a one-byte allocation of unresolved type held as void*: both frees call
  ::operator delete, the bare operator delete the image calls (0x8138b43), instead of deleting a void*.
- Consistent class keys for MSVC: GameTemplateConsoleAccess and MissileLockMessage are structs
  (MaskObjectTemplate.h, AIDllTypes.h declared them as classes; C4099). Neither name is in an export
  list.
- The AI's unused std::set::find results, which the image computes and discards, are cast to void
  (C4834).
- RendDX9Base.h defines WIN32_LEAN_AND_MEAN only when it is not already defined (C4005).

No behaviour change: PerformanceLogging stays null, the client deletes are unchanged, and the dedicated
pointers are provably null. Left as they are, because they encode the shipped arithmetic or are
third-party code: C4018 (signed/unsigned comparisons), C4334 (32-bit shifts in the AI), C4244 in
HudScoreboard.cpp, C5287 (GameSpy).

Validation: macOS bf2_client, bf2 and bf2_aidll build without the warnings above.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Destructor and warning fixes: complete delete types, class keys, nodiscard
Each cast states what the binary does; only the OBB vertex-count test changes behaviour, back to the
shipped signed comparison.

- C4018, the unsigned tick comparisons, now explicit: GameLogic::getTimeToNextStateChange (PE 0x464B30,
  unsigned), Player's heal and gave-ammo flags (unsigned), and Soldier's hit-by-vehicle window
  (ELF 0x081B67CF, cmp/jae).
- C4018, ResponsePhysicsManager::checkMeshObjectVsObjects' OBB stage: both vertex counts compare signed
  against the limit (ELF 0x0837185B jg, 0x08371AB6 jle). The implicit unsigned comparison differed from
  retail once a console write made the limit negative; the counts are now cast to int.
- C4334, the AI's control bits: `1 << key` is a 32-bit int shift that is then sign-extended to the
  64-bit mask (ELF libaidll BBPRevive 0x002994BE: shl, cltd). The shift is now explicitly an int at
  all eight sites; the widening is unchanged.
- C4244, HudScoreboard: m_field028 (only ever zero here) is passed to the float row-highlight
  parameter through an explicit cast.
- C5287, GameSpy's enum comparisons: the vendored C targets disable the warning; the SDK code stays
  as shipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Windows x64 build reported 60 warnings that the x86 build cannot show; none is a 64-bit defect.
- GameSpy (56): C4244/C4267 are string, packet and buffer lengths (size_t, pointer differences) held
  in int or DWORD; C4311/C4312 are buddy and block indices passed through a callback's void* user data
  and back (gpiBuddy.c, gpiProfile.c, int -> unsigned long -> void* -> int). Both round-trip
  losslessly at the sizes GameSpy handles, as in the x86 build. The vendored C targets disable these
  four warnings; the SDK code stays as shipped.
- PasswordCodec::readHexPairs and ::decode (4): the half-length of the stored hex string is a 32-bit
  count, as in the image; the size_t is now narrowed explicitly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remaining MSVC warnings: shipped comparisons and shifts made explicit
Markus Kraus and others added 25 commits November 15, 2026 11:57
PunkBuster exists only as 32-bit DLLs (pbcl.dll, pbsv.dll), and an x64
process cannot load them. The x64 client therefore takes the "PunkBuster
Client Not Installed" path and cannot join servers that require
PunkBuster. The x64 client README, the package table, the install steps
and the native x64 notes in building.md now say so, and point to the x86
client for those servers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Windows import listing now covers the x86 client too: BF2.exe,
RendDX9.dll and TextureAtlasBuilder.dll, next to the x86 editor's images.
The x64 leg also lists BF2OpenAL.dll. The step still fails on any
NovintHFX.dll import.

It also prints the embedded manifest of BF2.exe (both architectures) and
BF2Editor.exe with mt.exe, so the log shows their requestedExecutionLevel.
Any requestedExecutionLevel turns off UAC file virtualization, which
retail's manifest-less BF2.exe gets. The manifests are only printed, not
changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
[CHOSEN, not recovered] owner decision. Retail shipped Creative's 32-bit
OpenAL wrapper, renamed BF2OpenAL.dll. The x86 client now carries the
same pinned OpenAL Soft build as the x64 client (32-bit, same tarball,
same options, static MSVC runtime), so both clients use one provider.
BF2.exe runs from the package folder and the application folder is
searched first, so the bundled DLL wins over the game folder's retail
copy. The System OpenAL rows are unchanged.

- build_openal_soft.py takes --arch. BUILD.txt names the architecture.
- build.yml: both legs restore and build OpenAL Soft, cached per
  architecture. The import listing includes both BF2OpenAL.dll copies
  and fails if one imports the shared MSVC runtime. Only the x64 leg
  uploads the source tarball, so it stays one release asset.
- release.yml attaches the tarball with either Windows client.
- package_release.py: the x86 client manifest includes BF2OpenAL.dll and
  gets the same licence and notice (32-bit wording). Its README says the
  bundled DLL is used.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BF2_HITCH_TRACE=<file> writes one line per main-loop frame (duration,
mainLoop section times and the main-thread time spent on effect requests,
waits for native effect builds, device shader creation, Metal library and
pipeline compiles, state objects, texture uploads, captures, GPU waits and
drawable waits), one per effect request, one per finished background
effect build and one per input-script report line. Frames over
BF2_HITCH_TRACE_MS (default 33) also go to stderr. Without the variable
nothing changes; the trace is a measurement aid marked [TEMP].

Loopback: --hitch-trace writes <run>/hitch.trace; --bundle-id runs the
client from a bundle of its own so that Metal's per-bundle shader caches
start empty; hitch_report.py summarises a trace (frames over 33/50/100 ms,
the ones caused by build work, the worst frame per labelled moment).
Scenario first-shots draws and fires every weapon slot of four kits and
the M1A2 gun as labelled moments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every effect request scans its source and includes for #include lines
twice: the effect cache's include closure (Cache.cpp capture) and Ra's
include handler, which splices each include into its expanded copy. Both
matched every line with std::regex, about 1.7 ms and 2 ms per request in
libc++; a level load makes about 5,400 requests. Both now use a matcher
written out for the same pattern, with the same results (checked against
std::regex on random lines; the 4,007 recorded requests of a level load
keep their cache keys). Ra keeps std::regex for a file name with regex
syntax other than '.'.

Main-thread time in effect requests during a dalian_plant load: 29 s to
16 s with an empty effect cache, 26 s to 7 s with a full one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eated

A D3D9 driver compiles a shader at CreateVertexShader/CreatePixelShader,
during the level load. This port compiled each program's MSL with
newLibraryWithSource at its first draw, on the render thread: about
100-150 ms per pixel shader with an empty system shader cache, so the
first shot of each weapon stalled (up to 1.2 s).

Now every program's library is queued when its shader object is created
and compiled on background threads in batches of 64, each shader in a
namespace of its own, because most of a compile is a fixed cost per
source. Programs with equal MSL share one library. The vertex-fog variant
of a pixel shader below ps_3_0, which most BF2 draws use instead of the
shader's own program, is created with the shader. Natively built effects
create their device shaders at the next Present after their background
build finishes instead of at their first pass. A draw that needs a
library that is not compiled yet compiles it at once, or waits for the
thread that compiles it; nothing is drawn differently.

Pipeline states, which have no D3D9 counterpart, are still built by the
first draw that uses them; equal descriptions (shader MSL, attachments,
blend state, vertex attributes) share one state. Without colour writes no
fragment library is compiled for a draw. BF2_METAL_PREBUILD=0 turns the
background work off; BF2_METAL_PREBUILD_THREADS and _BATCH tune it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The pipeline states of a start missed the system shader cache on the next
start for shaders that were compiled differently: 30 states per warm
start were built anew (10-60 ms each) although the previous start had
built them. A shader's functions got another name when it was compiled
alone (at a draw, or as the only member of a batch: no namespace) and
other source positions when it sat at another line of another batch, and
both change the compiled code the cache is keyed by (checked offline: the
same vertex/pixel pair hits the cache from another batch only at the same
lines, and misses from the bare source).

Every shader is now compiled in its namespace l<hash>, numbered from line
1 of a file named after it (#line), whether alone or in a batch, so its
compiled form no longer depends on how the batches of a start were
composed. Pipeline states rebuilt on a warm start: 30 before, 12-26 after
in the measured runs; the rest have the very description the previous
start built (Metal's cache misses them), mostly interface states created
at the end of the load.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The include closure of an effect request parsed every file it visited
for #include lines again, although nearly every request includes the
same few files. The directives of a file are a pure function of its
bytes, so they are now kept by the SHA-256 the closure computes anyway.
The include handler is still called for every include, so the cache key
and the game's own include handling are unchanged. Offline over the
4,007 recorded requests of a dalian_plant load: 0.37 ms to 0.10 ms per
request, every key unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A draw whose pipeline state (or shader library) is not built yet stalls
the frame while the render thread builds it: with an empty system shader
cache 10-60 ms per state, and the first shot of a weapon needs several at
once (particles, muzzle flash, smoke, tracers).

[CHOSEN, not recovered] A colour-only blended draw (blending on, no depth
or stencil writes, no occlusion query) now does not wait: a worker builds
what it needs, ahead of the background library batches and at a higher
priority, and the draw is skipped until then and drawn from the first
frame after that. Nothing else in the frame depends on what such a draw
writes except the colour it blends into. Every other draw (opaque or
depth-writing geometry, weapon models, terrain) still builds or waits as
before. A traced run prints the skipped draws and, per state, the frames
the draw was missing. BF2_METAL_PREBUILD=0 also turns this off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…esent

Every Present committed the frame's command buffer and waited until the
GPU had executed it, and every texture upload and event query did the
same, so the CPU and the GPU never worked at the same time: about 19,500
waits (25-31 s) during a dalian_plant load and most of each frame in play.

[CHOSEN, not recovered] Present now submits without waiting, as a D3D9
driver queues frames, and waits only while two earlier frames are still
executing. A texture upload stays in the frame's command buffer, which
retains its staging buffer. An event query (D3DISSUE_END) submits the
work so far and returns a fence that GetData polls, instead of waiting for
the GPU; games issue one per frame to bound how far the CPU runs ahead.
What the CPU writes stays safe: DISCARD locks rename the buffer, other
buffer locks, readbacks, occlusion FLUSH, Reset and teardown still wait
for the GPU, constants and index copies go through buffers the command
buffer retains, and command buffers retain every resource they use. A
failed command buffer latches device loss when the GPU reports it. A
traced run prints the frame submissions, mid-frame flushes and waits for
a frame in flight.

first-shots (High, 8x MSAA, 800x600 windowed): median frame 23 ms to
10 ms, p95 36 ms to 20 ms; load 74 s to 57 s with empty caches, 60 s to
39 s with warm ones. The Metal device harness polls an event query until
the GPU has reached it, as RendDX9 does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
[CHOSEN, not recovered] owner decision. The Windows installer has two
modes: per-user (the default, no administrator rights) and all-users
(administrator rights, the retail registry).

Before the registry, the client now reads
%LOCALAPPDATA%\OpenBF2\Registry.dat: the Registry.con text, protected
with CryptProtectData (current user, no entropy, no UI). A value found
there wins. Without the file, or without the value in it, the registry
is read as before, so retail and all-users installs keep working. The
client only reads the file and never logs values.

The Registry.con parser moves to a shared registryFile namespace
(Core/RegistryFile.h), used by both the POSIX Registry.con and the
Windows Registry.dat. It now also skips a leading UTF-8 byte-order mark.

docs/registry-file.md is the installer contract. Its "All-users
installs" section covers retail's HKLM layout, including "x9392" plus
the hex of a CRYPTPROTECT_LOCAL_MACHINE blob, which CdKeyStore already
decrypts. The new tools/windows/new-registry-dat.ps1 writes test files.
The MSVC checks bf2_registry_dat_check and bf2_registry_dat_script (in
bf2_run_checks) round-trip fake keys through CryptProtectData and the
reader. Both client READMEs name the file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With frames in flight, a command buffer that fails on the GPU sets the
frame's asynchronous failure latch from its completion handler, and every
later submission turns the latch into device loss. Reset only cleared the
synchronous flag, so after a successful Reset the next Present reported
the device lost again and the game could not recover without a new
device. Reset now replaces the latch once the old submissions are drained.

The Metal device harness injected failures only into the synchronous
flag, which is why it missed this; the injected failure now also sets the
asynchronous latch, and the existing recovery checks (Reset, then Clear
and Present) fail without the fix and pass with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With BF2_HITCH_TRACE and BF2_PRESENT_PNG both set, the capture's trace
scope borrowed the capture's label, but the capture was deleted before
the scope ended, so the trace read freed memory (AddressSanitizer:
heap-use-after-free in the Metal device harness). The capture is now
owned by a unique_ptr declared before the scope. The harness under
AddressSanitizer with both variables set writes its captures and trace
records cleanly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…aults

Implement the intentional bounds policy discussed in #26 without changing valid packet formats or engine layouts. Extend the voice runtime fixture and document the client-only build dependency.
[CHOSEN, not recovered] owner decision. A release now carries one
package per platform, named by the platform only, so the release page
no longer lists per-role packages:

  openbf2-macos.dmg           the setup app with the universal client
  openbf2-windows.zip         x64\ and x86\ clients, x86 server\ and
                              editor\, licenses\, README, build-info
  openbf2-linux.zip           the x64 dedicated server
  openal-soft-1.25.2.tar.bz2  the LGPL source of BF2OpenAL.dll
  plus one .sha256 per file

The per-role and per-architecture ZIPs stay CI artifacts (packages-*).

- package_release.py --release windows|linux assembles the release ZIP
  from the per-role ZIPs: it checks each one's .sha256, build-info
  revision and runtime SHA-256s, puts runtime files in the component's
  folder, merges identical licence files, keeps each client's
  OpenAL-Soft-NOTICE.txt beside its DLL, checks the OpenAL Soft tarball
  against the notices and writes one README (the per-role READMEs'
  facts, per folder) and one build-info.json (components, link
  contracts, per-file SHA-256). Every input is verified first.
- --release macos writes openbf2-macos.build-info.json for the disk
  image (the image cannot hold it); a CI artifact, not a release asset.
- build.yml: a Windows package job assembles release-windows from both
  Windows legs; the Linux job adds release-linux; the macOS app job
  writes openbf2-macos.dmg as release-macos. The per-architecture macOS
  ZIPs are no longer notarized (no notary key in that job, no Apple
  submission); their binaries are still signed for the app.
- Without a usable D3DX source a release run fails at the probe, since
  a Windows package without its clients is not a release; other runs
  stay green and package what was built (--allow-missing), with the
  missing folders named in the README and build-info.json.
- release.yml attaches exactly the release-* assets after checking
  every checksum, refusing any other file and checking that the
  Windows package holds both clients, the server and the editor.
- The OpenAL Soft notice no longer says "in this package"; the FFmpeg
  licence is limited to the x64 client, whose renderer links it.
- Per-role ZIP text entries now carry regular-file mode bits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DataBlockManager::newDataBlock (ELF 0x808C7E0) allocates the 32-bit length that
DataBlockEvent::deSerialize (ELF 0x806F9F0) reads off the wire without any check,
so a peer can make the receiver attempt a 4 GB allocation (B2BF/OpenBF2 issue 2).

Refuse announcements above 1 MiB like a busy manager: nothing is allocated, the
block's chunks are dropped by addDataChunk, the connection is kept, and the first
refusal is logged. The largest fixed-size blocks are EndOfRoundInfo (7,166 bytes),
ServerInfo (895) and MapInfo (369); the map list and remote-console text grow with
their content but stay far below the limit.

bf2_datablock_cap_check sends normal blocks through the wire format and feeds a
4 GB, limit + 1 and limit-sized announcement.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rMessage

Retail dereferences the player in both without a null test: FireComp::requestFire
(ELF 0x82630C0) calls through it at 0x82630F7 whenever the template names an
ignored fire button, and HudChat::addPlayerMessage (BF2.exe 0x79F3E0) guards only
the ignore query (0x79F3EF) before calling getName (0x79F442). Crash guards from
B2BF/OpenBF2 PR 45, written as minimal deviations: requestFire skips only the
ignored-button test (the path retail already takes when no button is ignored),
addPlayerMessage drops the message.

The paintMapIcon texture guards are retail (BF2.exe 0x7746ED / 0x7CF02D,
test ebx,ebx; jle), so they get a comment saying so instead of a CHOSEN tag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Terrain::updateWaterConstants (RendDX9 0x100DBAD0) writes WaterCycleTime =
frac(GlobalTime / waterAnimSpeed) for the 3D water. The 3D water shaders offset
their volume texture by WaterScroll * WaterCycleTime and WaterCycleTime * 10, so
every wrap makes the whole surface jump (B2BF/OpenBF2 issue 69).

Keep a double-precision copy of GlobalTime, advanced at every GlobalTime
accumulation by the same frame time, and write the unwrapped cycle at the
retail rate. It wraps every 1000 cycles (7 to 28 hours for the stock animation
speeds), which keeps the float constant precise; at that period the texture
offsets move by whole numbers for scroll values with one decimal. The 2D water,
which uses the constant as a 0..1 frame blend, stays retail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fix VoIP packet bounds and the default Linux build
macOS Metal: shader builds off the render thread, frames in flight
Conflict in the packager: keep this branch's packaging, where every per-role
macOS ZIP is an un-notarized CI artifact; that already covers main's
"signed but not notarized" server README fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Windows: x86 + x64 clients (x64 without PunkBuster), x86-only server, Falcon archived, D3DX check, OpenAL Soft
Upstream review: data-block size cap, missing-player guards, continuous 3D water
@kr4uzi kr4uzi changed the title Feat/widescreen hud local Feat/widescreen hud local / Water Animation / FOV Nov 15, 2026
@kr4uzi kr4uzi closed this Nov 15, 2026
@kr4uzi
kr4uzi deleted the feat/widescreen-hud-local branch November 15, 2026 18:34
@kr4uzi

kr4uzi commented Nov 15, 2026

Copy link
Copy Markdown
Author

accidentally opend this pull request... was intended to go on my own fork

@kr4uzi
kr4uzi restored the feat/widescreen-hud-local branch November 15, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant