From 503b73046eeff85b6ad01569f7388a1ceb7f4971 Mon Sep 17 00:00:00 2001 From: N0VAN0M4LY <224130499+N0VAN0M4LY@users.noreply.github.com> Date: Sat, 28 Nov 2026 12:59:51 +0800 Subject: [PATCH] docs(server): restore source references in local service headers The unreviewed baseline shortened many file headers and dropped their sources: the research notes sections, architecture sections, stock script paths and client addresses. They are put back where the code still does what they describe, and the headers of research, modification and research action files now also describe the banked excess RP flow (cln_move_exp_to_unit, cln_move_exp_to_module) that the baseline added. Comments only. Checked: typecheck. --- .../src/char/actions/action-table.ts | 2 +- .../src/char/actions/price-table.ts | 9 ++++--- .../src/char/actions/research-actions.ts | 27 ++++++++++++++----- .../cloud-settings/cloud-settings-store.ts | 4 +-- .../src/game-modes/mode-definition.ts | 2 +- packages/local-service/src/local-service.ts | 4 +-- .../src/modifications/ammo-refill.ts | 26 +++++++++++++++--- .../modifications/module-research-target.ts | 8 +++--- .../src/modifications/module-state.ts | 25 ++++++++++------- .../src/modifications/module-status.ts | 6 ++--- .../src/profile/profile-crew-skills.ts | 3 ++- .../src/profile/profile-research-targets.ts | 2 +- .../src/profile/profile-vehicle-state.ts | 15 ++++++----- .../src/research/research-progress.ts | 18 ++++++++++--- .../src/research/research-rules.ts | 2 +- .../src/research/research-state.ts | 26 +++++++++++------- .../local-service/src/server/port-listener.ts | 7 ++--- .../local-service/src/store/store-web-api.ts | 3 ++- 18 files changed, 127 insertions(+), 62 deletions(-) diff --git a/packages/local-service/src/char/actions/action-table.ts b/packages/local-service/src/char/actions/action-table.ts index 08779a5..e4a9c71 100644 --- a/packages/local-service/src/char/actions/action-table.ts +++ b/packages/local-service/src/char/actions/action-table.ts @@ -1,4 +1,4 @@ -/** Char action names mapped to their protocol handlers. */ +/** Char action names mapped to their protocol handlers (full list of names: implementation notes). */ import type { AccountStore } from '../../accounts/account-store.ts'; import type { ClanStore } from '../../clans/clan-store.ts'; import type { CloudSettingsStore } from '../../cloud-settings/cloud-settings-store.ts'; diff --git a/packages/local-service/src/char/actions/price-table.ts b/packages/local-service/src/char/actions/price-table.ts index 9fe0e42..ed06db9 100644 --- a/packages/local-service/src/char/actions/price-table.ts +++ b/packages/local-service/src/char/actions/price-table.ts @@ -1,5 +1,6 @@ /** - * The price table the char server sends for cln_get_price_ex. + * The price table the char server sends for cln_get_price_ex (implementation notes, + * implementation notes). * * The client keeps the answer whole as its price table (aces.exe 2.61.0.37 0xeb7a88, job type * 0x21; stored in the save-data object at +0x3f5c0, which warpoints::init makes the price @@ -26,7 +27,7 @@ * skills{ { costGold:i } } skill point packs (0x916380) * unlocks{ { cost:i costGold:i } } unlocks for sale (0x9170c0) * items{ { cost:i costGold:i } } classic items for sale, price per piece - * (wp_get_item_cost, 0x10531e0) + * (wp_get_item_cost, 0x10531e0; implementation notes) * trophy{ { cost:i costGold:i } } classic trophy prices * } * trophy{ { ... } } classic trophy definitions & drop weights @@ -34,8 +35,8 @@ * Every entry is read as cost:i (silver lions), costGold:i (golden eagles), discount:i (percent * off, not sent: no discounts), each 0 when missing (so zero prices are left out); openCostGold * is the outright price of a modification before research progress (0xec0910). Anything the - * lookup does not find costs 0 for the client, which then offers it at 0. The prices are - * config/wpcost.blk value and costGold (decorations: config/skins.blk, decals.blk, + * lookup does not find costs 0 for the client, which then offers it at 0 (lab round 20). The + * prices are config/wpcost.blk value and costGold (decorations: config/skins.blk, decals.blk, * attachable.blk; unlocks: config/unlocks.blk), the same the purchase rules charge. */ import type { BlkBlock, BlkParam } from '@wto/blk'; diff --git a/packages/local-service/src/char/actions/research-actions.ts b/packages/local-service/src/char/actions/research-actions.ts index a72fc0d..2811698 100644 --- a/packages/local-service/src/char/actions/research-actions.ts +++ b/packages/local-service/src/char/actions/research-actions.ts @@ -1,12 +1,25 @@ /** - * Vehicle and modification research char actions. Sent via `char_send_blk` (job type 13), - * each updates the profile and answers the updated client profile: + * Research actions. All are sent with char_send_blk (job type 13), + * so the client applies each answer as a profile update and each answers the whole profile. * - * - `cln_set_researchable` (`shop_set_researchable_unit` `0x17a3e80` / - * `shop_set_researchable_unit_module` `0x17a3e00`): `unit:t, type:i` or `unit:t, mod:t`. - * - `cln_reset_researchable` (`shop_reset_researchable_unit` `0x17a3f00`): `country:t, type:i`. - * - `cln_convert_exp` (`shop_convert_free_exp_for_unit` `0x17a4ec0`): `unit:t, amount:i`. - * - `cln_move_exp_to_unit` / `cln_move_exp_to_module`: spend banked excess RP. + * cln_set_researchable (shop_set_researchable_unit, aces.exe 2.61.0.37 0x17a3e80): + * unit:t the vehicle to research + * type:i its vehicle type number + * or, for a modification (shop_set_researchable_unit_module, 0x17a3e00; implementation notes): + * unit:t the owned vehicle + * mod:t the modification to research + * cln_reset_researchable (shop_reset_researchable_unit, 0x17a3f00): the player closed the + * "research finished" prompt without choosing. + * country:t, type:i + * cln_convert_exp (shop_convert_free_exp_for_unit, 0x17a4ec0): free research points into a + * vehicle, paid with golden eagles. + * unit:t, amount:i research points + * cln_move_exp_to_unit (scripts/unit/unitActions.nut flushExcessExpToUnit): put the branch's + * banked excess research points (researchUnits//exp) into a vehicle. + * unit:t + * cln_move_exp_to_module (flushExcessExpToModule): put a vehicle's banked excess research + * points (hangar//excessExp) into one of its modifications. + * unit:t, mod:t */ import type { AccountStore } from '../../accounts/account-store.ts'; import type { EquipmentCatalogue } from '../../modifications/equipment-catalogue.ts'; diff --git a/packages/local-service/src/cloud-settings/cloud-settings-store.ts b/packages/local-service/src/cloud-settings/cloud-settings-store.ts index 8603437..b66cf3c 100644 --- a/packages/local-service/src/cloud-settings/cloud-settings-store.ts +++ b/packages/local-service/src/cloud-settings/cloud-settings-store.ts @@ -1,6 +1,6 @@ /** - * Per-player cloud settings persistence inside `/saves//cloud-settings/`. - * Keeping cloud settings inside each player's save directory means copying `saves//` + * Per-player cloud settings persistence inside `/saves//cloud-settings/` + *. Keeping cloud settings inside each player's save directory means copying `saves//` * to another machine or fresh client folder carries all game options, keybinds, HUD settings, * presets, and map preferences along automatically. * diff --git a/packages/local-service/src/game-modes/mode-definition.ts b/packages/local-service/src/game-modes/mode-definition.ts index f7de30b..674b595 100644 --- a/packages/local-service/src/game-modes/mode-definition.ts +++ b/packages/local-service/src/game-modes/mode-definition.ts @@ -12,7 +12,7 @@ * createEventGameMode). * - mission_decl.missions_list: mission name -> {} (a value may carry "enableIf" rank * limits, scripts/missions/mapPreferencesParams.nut; none are set). - * - tag: required, the script reads it unguarded (scripts/matching/matchingGameModes.nut, + * - tag: required, the script reads it unguarded (scripts/matching/matchingGameModes.nut, * onGameModesUpdated; local verification stopped there without it). Tag prefixes mark sub-modes * (night battles, small teams, bullet hell, nuclear escalation, naval EC; * SUB_GAME_MODE_TAG_PREFIXES in matchingGameModes.nut:28-42). diff --git a/packages/local-service/src/local-service.ts b/packages/local-service/src/local-service.ts index d4db19a..c109be7 100644 --- a/packages/local-service/src/local-service.ts +++ b/packages/local-service/src/local-service.ts @@ -1,6 +1,6 @@ /** - * Assemble the local service: data layer, save layer, rules, protocol-layer services, - * and the single loopback listening port. + * Assemble the local service: data layer, save layer, rules, + * protocol-layer services, and the single loopback listening port. */ import type { Server } from 'node:net'; import { AccountStore } from './accounts/account-store.ts'; diff --git a/packages/local-service/src/modifications/ammo-refill.ts b/packages/local-service/src/modifications/ammo-refill.ts index 13cddd5..2658423 100644 --- a/packages/local-service/src/modifications/ammo-refill.ts +++ b/packages/local-service/src/modifications/ammo-refill.ts @@ -1,10 +1,28 @@ /** * Initial full stocking and `autoRefillWeapons` Silver-Lion top-up for an owned vehicle's - * modifications, ammunition belts/shells, expendables, and secondary weapon presets. + * modifications, ammunition belts/shells, expendables (`tank_medical_kit_expendable`), and + * secondary weapon presets. * - * Returns the total Silver Lions spent on refilling consumed ammunition, expendables, and - * paid weapon presets during this call (`0` on initial free stocking or when `autoRefill` - * is disabled). + * Rules: + * 1. Zero-cost modifications (`isFree`) whose `requires` are all owned cannot be bought by the + * client (`weaponsPurchase.nut` `canBuyItem` rejects zero cost) and receive `count = 1` in + * name + topological order, honoring `defaultEnabled` and non-bullet `exclusiveGroup` mutual + * exclusion. + * 2. Free secondary weapon presets (`isFreeWeapon`, excluding `isWeaponForCustomSlot` containers) + * whose `requires` (direct + `sum_weapons` container inheritance) are all owned receive + * `count = 1` so `shop_is_weapon_purchased` allows selecting them. + * 3. Silver-Lion counted modifications (`isCounted` with `goldenEagles === 0`, covering all + * 12,800 shells, gun belts, and `tank_medical_kit_expendable`) and paid weapon presets + * (`isPaidWeapon` with `goldenEagles === 0`) whose `requires` are all owned: + * - When no profile record exists yet (`record === undefined`, i.e. newly acquired vehicle or + * newly unlocked prerequisite modification), receive their initial full load (`maxCount`) + * at no extra Silver-Lion charge (`itemInfo.nut` `getAllModsCost` skips `maxAmount > 1`). + * - When a record already exists with `count < maxCount` (consumed in battle) and hangar + * `autoRefillWeapons` is enabled, buy as many missing pieces with Silver Lions in + * deterministic name order as the player's balance affords. + * + * Returns the Silver Lions spent on refilling (0 for the initial free stock and when + * autoRefill is off); battle settlement lists it as the automatic refill cost. */ import type { BlkBlock } from '@wto/blk'; import type { ModificationFacts, VehicleEquipment, WeaponFacts } from '../game-data/datasets/vehicle-equipment.ts'; diff --git a/packages/local-service/src/modifications/module-research-target.ts b/packages/local-service/src/modifications/module-research-target.ts index 26143af..ab31c9d 100644 --- a/packages/local-service/src/modifications/module-research-target.ts +++ b/packages/local-service/src/modifications/module-research-target.ts @@ -1,7 +1,9 @@ /** - * Choosing the modification an owned vehicle researches (`cln_set_researchable` with - * `unit:t` and `mod:t`) and pouring banked `excessExp` into a modification - * (`cln_move_exp_to_module`). + * Choosing the modification a vehicle researches: cln_set_researchable + * with unit:t and mod:t (script shop_set_researchable_unit_module). The modification has to be + * researchable now; it goes into hangar//investMode, and the client shows it as "in + * research" from there. cln_move_exp_to_module (scripts/unit/unitActions.nut + * flushExcessExpToModule, unit:t mod:t) puts the vehicle's banked excessExp into a modification. */ import type { BlkBlock } from '@wto/blk'; import { ownedVehicles } from '../profile/profile-hangar.ts'; diff --git a/packages/local-service/src/modifications/module-state.ts b/packages/local-service/src/modifications/module-state.ts index 11faef1..ccda7f6 100644 --- a/packages/local-service/src/modifications/module-state.ts +++ b/packages/local-service/src/modifications/module-state.ts @@ -1,13 +1,20 @@ /** - * Keeping every owned vehicle's modification state synchronized with its owned equipment - * and modification research points: - * - grants newly unlocked free items, stocks newly unlocked counted items, and runs SL - * top-ups when `autoRefillWeapons` is enabled; - * - writes `hangar//tierNumber` and `modsResearch` statuses; - * - maintains `investMode` so finished-modification prompts (`investModePrev != ""`) open - * `WeaponsModalHandler` in `researchMode` when researchable modifications remain (or signal - * `isResearchLast` with `investMode = ""` when the vehicle is spaded), without overwriting - * an intentionally empty `investMode` while `excessExp > 0` inside the modal. + * Bringing the modification state of a profile up to date, like research/research-state.ts does + * for vehicles: whenever a profile is handed out or changed (profiles-setup.ts), for every owned + * vehicle (sorted by name for deterministic auto-refill deduction): + * modifications & weapons unlocked free items, initial full stock of newly unlocked + * ammunition / expendables / paid presets, and Silver-Lion + * top-ups when `autoRefillWeapons` is enabled (ammo-refill.ts) + * hangar//tierNumber the highest open tier + * modsResearch the status of every modification not owned yet; locked ones + * only keep an entry while they hold research points + * hangar//investMode cleared when that modification is no longer researchable + *. After a modification finished + * (investModePrev set) a new one is picked while some remain, so + * the stock prompt opens WeaponsModalHandler in researchMode + * (or reports isResearchLast with investMode "" when the vehicle + * has nothing left); with banked hangar//excessExp and + * nothing just finished it stays empty for the player to choose. */ import type { BlkBlock } from '@wto/blk'; import type { VehicleEquipment } from '../game-data/datasets/vehicle-equipment.ts'; diff --git a/packages/local-service/src/modifications/module-status.ts b/packages/local-service/src/modifications/module-status.ts index e3e2f80..e3682b7 100644 --- a/packages/local-service/src/modifications/module-status.ts +++ b/packages/local-service/src/modifications/module-status.ts @@ -1,7 +1,7 @@ /** - * The status of each modification of an owned vehicle. The client works out "owned" and - * "mounted" from the modifications records and "in research" from `investMode` itself; the - * server supplies the rest through `modsResearch`: + * The status of each modification of an owned vehicle. The client + * works out "owned" and "mounted" from the modifications records and "in research" from + * `investMode` itself; the server supplies the rest through `modsResearch`: * * researchable modification (tier 1+, research points) * tier not open LOCKED diff --git a/packages/local-service/src/profile/profile-crew-skills.ts b/packages/local-service/src/profile/profile-crew-skills.ts index d83e144..e37044c 100644 --- a/packages/local-service/src/profile/profile-crew-skills.ts +++ b/packages/local-service/src/profile/profile-crew-skills.ts @@ -1,5 +1,6 @@ /** - * Crew skills, skill points, specializations, and Expert-to-Ace RP inside a crew block: + * Crew skills, skill points, specializations, and Expert-to-Ace RP inside a crew block + *: * * crews{ * c0{ diff --git a/packages/local-service/src/profile/profile-research-targets.ts b/packages/local-service/src/profile/profile-research-targets.ts index 020ecc9..497ea79 100644 --- a/packages/local-service/src/profile/profile-research-targets.ts +++ b/packages/local-service/src/profile/profile-research-targets.ts @@ -1,6 +1,6 @@ /** * Current research target, just-finished research vehicle, and banked excess RP per country - * and vehicle branch (`aces.exe` `0x930150`): + * and vehicle type (implementation notes; `aces.exe` `0x930150`): * * researchUnits{ * country_usa{ diff --git a/packages/local-service/src/profile/profile-vehicle-state.ts b/packages/local-service/src/profile/profile-vehicle-state.ts index 399b7a5..918ae0a 100644 --- a/packages/local-service/src/profile/profile-vehicle-state.ts +++ b/packages/local-service/src/profile/profile-vehicle-state.ts @@ -1,11 +1,12 @@ /** - * Per-vehicle fields of owned vehicles under `hangar{ { ... } }`, read by name in - * `AircraftInfo::serialize` (`aces.exe` `0x940510`): - * investMode:t the modification currently selected for research (`+0x100`) - * investModePrev:t the modification whose research just finished (`+0x108`) - * tierNumber:i the highest open modification tier - * spareAircraftsCount:i vehicle-specific backups owned - * excessExp:i64 banked modification overflow RP (`+0x70`) + * Per-vehicle fields of owned vehicles: hangar{ { ... } }, + * read by name by AircraftInfo::serialize (aces.exe 2.61.0.37 0x940510). Only the fields the + * local service maintains are handled here: + * investMode:t the modification being researched, empty = none (AircraftInfo+0x100) + * investModePrev:t the modification whose research just finished (+0x108) + * tierNumber:i the highest open modification tier (script is_tier_available) + * spareAircraftsCount:i spares the player has for this vehicle + * excessExp:i64 banked modification research points (+0x70) */ import { findBlock, findParam, setParam, type BlkBlock } from '@wto/blk'; diff --git a/packages/local-service/src/research/research-progress.ts b/packages/local-service/src/research/research-progress.ts index 222e9d2..37cd112 100644 --- a/packages/local-service/src/research/research-progress.ts +++ b/packages/local-service/src/research/research-progress.ts @@ -1,7 +1,19 @@ /** - * Choosing a vehicle research target (`cln_set_researchable`), dismissing a finished-research - * prompt (`cln_reset_researchable`), converting free RP (`cln_convert_exp`), and investing - * banked branch excess RP (`cln_move_exp_to_unit`). + * Choosing what to research and putting research points into a vehicle (implementation notes + * sections 1.2, 4.3 and 5). + * + * - Choosing a research target (cln_set_researchable) makes a researchable vehicle the + * target of its country and type and closes the "research finished" prompt. + * - Dismissing that prompt (cln_reset_researchable) only closes it. + * - Converting free research points (cln_convert_exp) costs the points and golden eagles: + * one golden eagle per researchPointsPerGoldenEagle points, rounded up. The stock window + * (scripts/convertExp/convertExpHandler.nut) never asks for more than the vehicle still + * needs; more is cut down to that. + * - Spending banked excess research points (cln_move_exp_to_unit) puts the branch's + * researchUnits//exp into the chosen vehicle, up to what it still needs. + * - When a vehicle's research points reach what it needs and it is the target, the target is + * cleared and the vehicle recorded as just finished, which makes the client offer the next + * research (research-state.ts). */ import type { BlkBlock } from '@wto/blk'; import { balanceOf, pay } from '../profile/profile-currency.ts'; diff --git a/packages/local-service/src/research/research-rules.ts b/packages/local-service/src/research/research-rules.ts index c1a9f93..b1a5467 100644 --- a/packages/local-service/src/research/research-rules.ts +++ b/packages/local-service/src/research/research-rules.ts @@ -1,6 +1,6 @@ /** * Static facts used by vehicle research and purchase rules, loaded once at startup from game - * files. + * files (implementation notes; implementation notes). */ import type { DatasetCache } from '../game-data/datasets/dataset-cache.ts'; import { crewSlotPrices, eraRequirements, type CrewSlotPrices, type EraRequirements } from '../game-data/datasets/rank-settings.ts'; diff --git a/packages/local-service/src/research/research-state.ts b/packages/local-service/src/research/research-state.ts index 6fb6ad6..a43c555 100644 --- a/packages/local-service/src/research/research-state.ts +++ b/packages/local-service/src/research/research-state.ts @@ -1,13 +1,21 @@ /** - * Keeping a player's vehicle research state consistent with owned vehicles, earned unlocks, - * and branch research progress: - * 1. Open ranks and earn unlocks until neither changes anything. - * 2. Write every non-owned vehicle's status into `unitResearch`. - * 3. Maintain `currUnit` without overwriting an intentionally empty target while - * banked `exp` is being spent inside `ShopCheckResearch`, while seeding a default - * target on brand-new branches (`currUnit === "" && prevUnit === "" && excessRp === 0`) - * and autosetting a 0-RP cursor candidate when `prevUnit !== ""` so stock - * `researchActions.nut` (`checkNonApprovedResearches`) opens `ShopCheckResearch`. + * Bringing the research state of a profile up to date. The char + * server keeps it current online; the local service does it whenever a profile is handed out + * or changed (profile/player-profiles.ts), so the state always follows from the facts: + * owned vehicles, research points, earned unlocks, banked excess research points. + * + * 1. Open ranks and earn unlocks until neither changes anything (an unlock can give a vehicle, + * a vehicle can open a rank, a rank can earn an unlock). + * 2. Write every vehicle's status into unitResearch: owned vehicles have no entry, locked + * vehicles only keep one while they hold research points. + * 3. Keep every branch researching while it can: a target that is no + * longer researchable (bought, researched, ...) is cleared, and a new one is picked by + * auto-research-target.ts when the branch has just finished a vehicle (prevUnit set: the + * stock scripts then open the "choose the next research" window, ShopCheckResearch, from + * scripts/researches/researchActions.nut checkNonApprovedResearches) or has no banked + * exp. With banked RP and nothing just finished it stays empty, so the player chooses + * where the RP goes (cln_move_exp_to_unit). A branch with nothing left to research has its + * banked RP cleared. */ import type { BlkBlock } from '@wto/blk'; import { ownedVehicles } from '../profile/profile-hangar.ts'; diff --git a/packages/local-service/src/server/port-listener.ts b/packages/local-service/src/server/port-listener.ts index 5fdc393..fcfb11f 100644 --- a/packages/local-service/src/server/port-listener.ts +++ b/packages/local-service/src/server/port-listener.ts @@ -1,8 +1,9 @@ /** * The local service's single listening port. Every address in the game's network.blk points - * here, and the network hook library routes all other outbound game connections here as well. - * The first bytes of a connection decide which protocol handler accepts it: - * - Matching binary packet (first byte 1) -> MatchingService; + * here, and the network hook library routes all other outbound game + * connections here as well (5.1). The first bytes of a connection decide which protocol handler + * accepts it: + * - Matching binary packet (first byte 1, matching/matching-frame.ts) -> MatchingService; * - Plaintext IRC handshake (`PASS` / `NICK` / `USER` / `CAP` / `PING`) -> IrcServer; * - TLS ClientHello (record type 0x16) -> decrypted with the local certificate, then routed * to IrcServer or the HTTP server based on the first decrypted bytes; diff --git a/packages/local-service/src/store/store-web-api.ts b/packages/local-service/src/store/store-web-api.ts index b665fac..fcb863b 100644 --- a/packages/local-service/src/store/store-web-api.ts +++ b/packages/local-service/src/store/store-web-api.ts @@ -1,5 +1,6 @@ /** - * The JSON requests of the local store page (/store, shown in the game's built-in browser): + * The JSON requests of the local store page (/store, shown in the game's built-in browser; + * implementation notes): * GET /store/api/state?userId= balances, products and redeem code help for one account * POST /store/api/buy { userId, productId } * POST /store/api/cart { userId, productId, action }