Commit Graph
16 Commits
Author SHA1 Message Date
N0VAN0M4LY 6ce93ee962 Have the LocalMP modules read their addresses and offsets from the build
wto_ws.dll no longer scans aces.exe or carries structure offsets of a game
build. It reads the values the patcher resolved (wto_ws.cfg native.* lines)
into g_lmp through one table that names, per module, which value fills which
field (local_mp_values.c), and installs each module whose values are all
present, in dependency order, instead of giving up on the whole bridge when
one subsystem is missing. When the settings were resolved for another
executable (PE time stamp and image size differ), the bridge stays off.

local_mp_offsets.h keeps the existing names so the module code reads as
before; only Dagor library layouts (dag::Vector, DataBlock), protocol enums,
the reflection buffer size and the two change request members with no reader
in the client remain constants. A few fields are derived where the client has
no instruction of its own for them (local_mp_values.c derive_values). The
signatures moved to patches/native, and the header-based check-offsets
command is gone: record-game-version and the launcher's patch check resolve
the native modules now.

Shared sites moved to local_mp_core (mission customBots, the player's unit
eid) so modules do not depend on each other for them.

Checked: DLL build (no warnings outside MinHook); root and launcher type
checks; check-patches on 2.61.0.37; version records for 2.61.0.37 and
2.61.0.43 (10 native modules each); a lab run of the 2.61.0.37 copy logs
239 native values and "9 of 9 LocalMP modules installed". Battles were not
played in this run.
2026-11-29 12:26:11 +08:00
N0VAN0M4LY 5df305e2f9 Make source comments and build tools self-contained 2026-11-29 08:46:08 +08:00
N0VAN0M4LY 27fc535301 Split the repository into apps, packages and patches
Everything sat in packages/: two programs next to the small libraries
they use, and the patch data loose at the root. The programs now live in
apps/ and the shared libraries in packages/:

  apps/server        the local server (was packages/local-service),
                     package @wto/server
  packages/patcher   builds the game copy (was packages/build),
                     package @wto/patcher
  patches/exe        exe patch definitions (was exe-patches)
  patches/gui        GUI script patches (was gui-patches)

Inside the server, the network layer folder becomes transport/ so it is
not server/server/, the entry module is server.ts, and startLocalService
and its types become startServer, ServerOptions and RunningServer. The
health answer names the app wto-server, and the TLS files in the data
folder are server.key and server.crt (made again on the next start).
Comments, logs and tool texts say "local server".

The patcher no longer reaches into the server's folder. It read the
default tuning/store.jsonc by a relative path to register bundle GUIDs
for the multi-vehicle packs, which also ignored the player's overrides
in <data>/tuning/. It now takes the pack ids from its caller; the
server exports multiVehiclePackIds(dataFolder), which reads them the way
the running server does. rebuildGuiPack takes the patch folder from its
caller as well.

The development build moves out of the patcher to
scripts/build-game-copy.ts, since it uses both the server and the
patcher. It needs --data (the folder the server will run with) and
defaults the patch folders and the hook library to this repository.


Checked with the root typecheck, check-patches, check-gui,
check-offsets, the native build, a run of build-game-copy.ts into a
scratch folder (12 exe patches, 35 GUI patches, 496 bundle GUIDs as
before) and a server start from apps/server answering wto-server.
2026-11-29 03:20:54 +08:00
N0VAN0M4LY f6cdab7ec7 Free the support unit reference after control returns
Clearing missionSupportUnitRef as soon as the support unit died kept the
player from getting the vehicle back: the unit update (2.61.0.37
0xfd1450, 0xfd2f01 / 0xfd25a7) recognises the player's dead support
unit by that reference (unit +0x88 == MPlayer +0xb58) and only then calls
setControlledUnit(mp, 0) (0x598a70) to return control. In game the
camera stayed on the wreck until the player respawned.

Remember the player and the dead unit's entity id at the death, and
clear the reference after setControlledUnit has run for that player
(new hook, LMP_SIG_SET_CONTROLLED_UNIT, 2.61.0.37 hit 0x598a70), as
long as it still names that unit.

Checked with the native build and check-offsets; not yet verified in
game.
2026-11-29 02:53:34 +08:00
N0VAN0M4LY 2065514d16 Free a destroyed mission support unit on the LocalMP host
After the first nuclear carrier was shot down, the next launch respawned
it in the air where it died and the player could not fly it. The host
gives a player a support unit only while missionSupportUnitRef (MPlayer
+0xb50 / +0xb58) is empty (2.61.0.37 0x59d9c8), and the client clears
the reference only when the player is re-initialised, never during a
battle. The second launch reused the dead unit: control was refused
("changed controlled unit to already dead unit"), and without an owner
the respawn (0xe4fdf0) placed it at its old position instead of an
airfield.

Clear a player's reference when the unit it names dies (in the existing
onUnitDeadOnce hook, host only), so the stock update creates a new
support unit the next time the spawn score threshold is reached.

Checked with the native build and check-offsets; not yet verified in
game.
2026-11-29 02:37:19 +08:00
N0VAN0M4LY 6ab941a086 Award the nuclear strike in LocalMP battles
Online the battle server gives killStreak_bomber_nuclear_success (mode
killStreakNuclearSuccess, 10000 SL) when a player's nuclear bomb
explodes; the LocalMP host has no battle server, so the award was never
given.

The native nuke module now remembers whether the local player launched
the instant-win bomb and, when it explodes, raises the HUD script event
wtoLocalMpNuclearStrike. The battle record keeps it as a strike, sends
it live (wto_battle.fact kind "strike") and reports it after the battle
(strikes{}); the local service awards killStreakNuclearSuccess once per
strike, live as the award banner and in the settlement.

Checked with typecheck, check-gui, check-offsets and the native build;
not yet verified in game.
2026-11-28 19:03:24 +08:00
N0VAN0M4LY 752346d877 Read mission variable values at +0x10
cta_logic_action walks the variable array with r15 = entry+8, compares the name
at [r15-8] and takes the value at r15+8 (0x11bd1a6), so the int value is at
entry+0x10; the nuclear win wrote the wrong field and the tickets stayed.
2026-11-28 18:31:43 +08:00
N0VAN0M4LY 1c32dc71b0 Take the nuclear win at the projectile explosion handler
create_nuke_destr_area_es does not run on the LocalMP host. The projectile
explosion handler 0xbe7c00 gets the launch record's instant-win flag as its
8th argument (0x2fd778 / 0x2fd7c3) and is what plays the nuclear explosion,
so the winner is now taken there.
2026-11-28 18:10:39 +08:00
N0VAN0M4LY f470585136 End a LocalMP battle on a nuclear instant-win explosion
Online the battle server ends the battle when a bomb with isInstantWinOnExplode
explodes; the 2.61.0.37 client only flags the bomb, so the LocalMP host played on.
The host now remembers the team of a flagged bomb (0x1431c10), takes it as the
winner when create_nuke_destr_area_es runs (0x63caf0), and zeroes the loser's
mission ticket variable before cta_logic_action (0x11bc400), which then ends the
battle the stock way.
2026-11-28 17:57:47 +08:00
N0VAN0M4LY 1ce54df4c0 Describe what the LocalMP loadout module does in its header
The header of local_mp_loadout.c still named per-unit economic multipliers that
the economy rework removed from the module. It now says what the module does: on a
host the client has no receiver for its own vehicle change request, so the send
hook builds the ChangeUnitReflection and calls Unit::changeAircraft. Comment only.

Checked: native build, check-offsets.
2026-11-28 13:03:29 +08:00
N0VAN0M4LY c17c3d3384 Narrow the LocalMP native bridge to documented engine gaps
- Scoreboard scores come from the local service: BattleEconomy
  missionScores() writes the official mission scores into the stock
  mission block customScoreParams, which the client copies into
  MissionSettings+0x6d8 without reading it; local_mp_scores.c reads them
  with DataBlock::getReal. The hardcoded scores and the death score go.
- countActivePlayers already counts players with a living vehicle; the
  only LocalMP gap is its filter skipping bots (MPlayer+0x1d8 bit 7). A
  one-byte exe patch drops that filter bit instead of a rewrite hook.
- ucavLaunch returns early on a host; an exe patch skips that return
  instead of clearing the global host flag around the call.
- onBecameDead no longer runs with isLocalMP cleared: that only queued an
  EventOnPlayerDeath stock LocalMP skips on purpose, and broke the local
  player id remap inside the function.
- The host chat object keeps its two-field layout, now documented from
  the host chat handler that reads it.
2026-11-28 07:09:07 +08:00
N0VAN0M4LY 7f570c85c3 Price LocalMP battle rewards in the local service
The LocalMP host has no battle server, and the previous bridge filled the
gap by computing money in the client: the native ledger wrote invented
amounts into SessionStatsNet, the spawn patch derived reward rates from
warpoints.blk, and the settlement patch summed and rescaled the result.
Rewards came out as zero or several orders of magnitude too high.

Now the client reports facts and the local service prices them.

Native (wto_ws.dll):
- local_mp_ledger.c is removed together with its SessionStatsNet
  offsets and four signatures (43 -> 39).
- local_mp_awards.c raises the HUD script event wtoLocalMpExpEvent for
  every combat event of the local player (event code, victim expClass
  and name, player or AI victim, friendly, naval damage). The DataBlock
  helpers and the HUD event queue are resolved from call sites inside
  GameSaveData::addScoreMessage, which already has a signature.

GUI patches:
- record-local-battle-awards records events and lives in nestdb and
  raises the stock InBattleReward banner from launch-time parameters.
- report-local-battle-settlement sends only facts and rebuilds the
  debriefing from the settled table; failures show the stock error box.
- use-settled-debriefing-stats makes gatherDebriefingResult read that
  table instead of the empty stat_get_exp().
- pass-spawn-modifications-blk no longer computes economy factors.

Local service:
- battle-economy dataset reads every reward factor from wpcost.blk,
  warpoints.blk and rank.blk; tuning/battle-economy.jsonc holds the
  mission score per event with its source (official values where
  published, otherwise marked).
- battle-economy.ts is the single pricing function, shared by the
  banner parameters and the settlement; battle-rewards.ts adds battle
  time, timed award, win/defeat bonus, activity, premium account,
  talisman, skill bonus and free research points; the debriefing table
  has the stat_get_exp() layout and travels in EULT_SESSION_RESULT.
- Crews earn skill points from the battle's research points.
- A battle left before it ends counts as a defeat.

Verified: npm run typecheck, check-gui (35 patches), check-patches,
check-offsets, native build. Not yet run in game.
2026-11-28 04:42:27 +08:00
N0VAN0M4LY 6a189513b0 Snapshot unreviewed LocalMP battle work as rework baseline
Records the uncommitted battle-session work exactly as it was left
(local service matchmaking, settlement, chat, native LocalMP hooks,
battle gui/exe patches) so the following review and rework commits
show every correction as a diff against this state.

This commit is not reviewed and is known to be incomplete: in-game
testing reported wrong settlement rewards, single-country teams,
missing random/fixed supplement slots, misattributed hit messages and
other regressions. Do not merge this branch before the rework lands.
2026-11-28 03:15:47 +08:00
N0VAN0M4LY d95a5d8f0c Complete local HTTPS handling and allow shared log reads
Use the loopback service certificate for the offline HTTPS path. Retain
original host names for host-based routing and allow the network log
to be read while the client is running.
2026-11-25 06:05:20 +08:00
N0VAN0M4LY 6e11156b90 Preserve stock socket export ordinals
Keep the original ordinals for functions imported by number so Windows
can resolve the socket library imports during startup.
2026-11-25 05:04:28 +08:00
N0VAN0M4LY afb22c4f08 Route client traffic to the loopback service
Build the socket library and client-local port configuration for redirecting
traffic to the offline service. Accept HTTPS and the existing matching and
HTTP protocols on the same port. Route requests by the original host.
2026-11-25 05:02:34 +08:00