Fix squadron persistence and align inventory wire formats

Read squadron action parameters from the request headers and persist
squadron state on profile refresh. Use floating-point trophy weights
to match the client probability display and assign unique log IDs
when opening multiple chests.

Tighten shop, marketplace, squadron, and cloud settings validation.
Move PBBD and inventory encoding into the protocol modules and share
CSV reading. Update the research and acceptance instructions.

Type checking and all eight executable patch checks passed.
In-game acceptance is pending.
This commit is contained in:
N0VAN0M4LY committed 2026-11-25 09:10:09 +08:00
1 parent 0b604c76f1
commit 8012cf7954
40 files changed
+1347 -1248

No files matched your search

@@ -1,24 +1,19 @@
/**
* The profile as the char service hands it to the client: the saved profile plus the
* account data and state the char server keeps outside the profile.
* account data and server clock the char server attaches on the wire.
*
* charDrivenNick: the client reads the player's nick from this top-level string when it
* loads a profile (name looked up at aces.exe 2.61.0.37 0x8fe0aa, value stored at 0x91874d).
* A profile without it clears the nick, and the online initialisation then fails with
* "[CONNECT] nick is empty" and error 0x81110017 (0x164e5cf), as seen in the lab runs.
* The nick belongs to the account, so it is added here rather than kept in the save.
*
* serverTime:i64: the char server's clock; without it the client
* takes the server time as 0 and every expiry and time limit is wrong.
*/
import { setParam, type BlkBlock } from '@wto/blk';
import type { Account } from '../accounts/account-store.ts';
import type { ClanStore } from '../clans/clan-store.ts';
import { serverTimeNow } from './server-time.ts';
export function clientProfile(saved: BlkBlock, account: Account, clans?: ClanStore): BlkBlock {
export function clientProfile(saved: BlkBlock, account: Account): BlkBlock {
const profile = structuredClone(saved);
clans?.syncProfile(profile, account);
setParam(profile, 'charDrivenNick', { type: 'string', value: account.nick });
setParam(profile, 'serverTime', { type: 'int64', value: serverTimeNow() });
return profile;
@@ -2,9 +2,9 @@
* The one way services get a player's profile: the saved one, or a new one that is written
* to the save before it is handed out.
*
* State that follows from the rest of the profile (statuses, open ranks, earned unlocks:
* research/research-state.ts) is brought up to date every time a profile is handed out or
* changed, and saved with it, so it also follows a game update that changed the data.
* State that follows from the rest of the profile (clan sync, statuses, open ranks, earned
* unlocks: research/research-state.ts) is brought up to date every time a profile is handed
* out or changed, and saved with it, so every action returns a consistent persisted profile.
*/
import type { BlkBlock } from '@wto/blk';
import type { GameFiles } from '../game-data/game-files.ts';
@@ -13,7 +13,7 @@ import { newProfile } from './new-profile.ts';
import type { StartingContent } from './starting-content.ts';
/** Brings the derived state of a profile up to date, in place. */
export type ProfileRefresh = (profile: BlkBlock) => void;
export type ProfileRefresh = (profile: BlkBlock, userId: string) => void;
export class PlayerProfiles {
readonly #saves: SaveStore;
@@ -30,7 +30,7 @@ export class PlayerProfiles {
profileOf(userId: string): BlkBlock {
const profile = this.#saves.loadProfile(userId) ?? newProfile(this.#gameFiles.newAccountTemplate(), this.#startingContent);
this.#refresh(profile);
this.#refresh(profile, userId);
this.#saves.saveProfile(userId, profile);
return profile;
}
@@ -50,7 +50,7 @@ export class PlayerProfiles {
updateWhen(userId: string, change: (profile: BlkBlock) => boolean): BlkBlock | undefined {
const profile = this.profileOf(userId);
if (!change(profile)) return undefined;
this.#refresh(profile);
this.#refresh(profile, userId);
this.#saves.saveProfile(userId, profile);
return profile;
}