Compare commits
10
Commits
7bd17c4f74
...
662e837ab2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
662e837ab2 | ||
|
|
deffcd6dde | ||
|
|
4e72bf3746 | ||
|
|
5c09c4e47a | ||
|
|
dce9b59765 | ||
|
|
e8122d7c6b | ||
|
|
4999c7f5a3 | ||
|
|
d0e4797fe7 | ||
|
|
f1ec034994 | ||
|
|
646be7afb9 |
No files matched your search
@@ -1,7 +1,12 @@
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import { cp, lstat, mkdir, realpath, rm } from 'node:fs/promises';
|
||||
import { dirname, isAbsolute, join, relative } from 'node:path';
|
||||
import { isInSteamLibrary, playerDecalCacheProblem } from '@wto/patcher';
|
||||
import {
|
||||
isInSteamLibrary,
|
||||
playerDecalCacheProblem,
|
||||
resolvePlayerDecalCacheFolder,
|
||||
writeDecalCacheIndexSnapshot,
|
||||
} from '@wto/patcher';
|
||||
import { AppError } from '@shared/errors.ts';
|
||||
import type { Copies } from '@shared/schemas/install.ts';
|
||||
import { canonicalCopyPath, copyPathContains, listCopies, steamLibraryNeedsConfirmation, updateCopyRecord } from './install-record.ts';
|
||||
@@ -33,8 +38,13 @@ export async function importDecalCache(
|
||||
dataPath: string, sourcePath: string, signal?: AbortSignal, steamDataConfirmed = false,
|
||||
): Promise<string> {
|
||||
if (!isAbsolute(sourcePath)) throw new AppError('decal_source_invalid');
|
||||
const source = await realpath(sourcePath).catch(() => null);
|
||||
if (!source || playerDecalCacheProblem(source)) throw new AppError('decal_source_invalid');
|
||||
const rawSource = await realpath(sourcePath).catch(() => null);
|
||||
const source = rawSource ? await realpath(resolvePlayerDecalCacheFolder(rawSource)).catch(() => null) : null;
|
||||
const problem = source ? playerDecalCacheProblem(source) : 'selected folder could not be resolved';
|
||||
if (!source || problem) {
|
||||
console.warn('[decals] invalid decal cache source:', sourcePath, '->', problem);
|
||||
throw new AppError('decal_source_invalid');
|
||||
}
|
||||
|
||||
const root = await cacheRoot(dataPath, steamDataConfirmed);
|
||||
if (copyPathContains(source, root) || copyPathContains(root, source)) {
|
||||
@@ -56,7 +66,12 @@ export async function importDecalCache(
|
||||
},
|
||||
});
|
||||
signal?.throwIfAborted();
|
||||
if (playerDecalCacheProblem(target)) throw new AppError('decal_source_invalid');
|
||||
writeDecalCacheIndexSnapshot(source, target);
|
||||
const copiedProblem = playerDecalCacheProblem(target);
|
||||
if (copiedProblem) {
|
||||
console.warn('[decals] copied decal cache failed validation:', copiedProblem);
|
||||
throw new AppError('decal_source_invalid');
|
||||
}
|
||||
return id;
|
||||
} catch (error) {
|
||||
await discardDecalCache(dataPath, id, steamDataConfirmed);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { readFileSync, realpathSync } from 'node:fs';
|
||||
import { relative } from 'node:path';
|
||||
import type { MessageEvent } from 'electron';
|
||||
import { assertWritableCopy, buildGameCopy, copyPlayerDecalCache, playerDecalCacheProblem, readStockGameFiles, writeGameCopy, type GameCopyFile } from '@wto/patcher';
|
||||
import { assertWritableCopy, buildGameCopy, copyPlayerDecalCache, playerDecalCacheProblem, readPlayerDecalIndexFiles, readStockGameFiles, writeGameCopy, type GameCopyFile } from '@wto/patcher';
|
||||
import { multiVehiclePackIds } from '@wto/server';
|
||||
import type { BuildCommand, BuildReply, BuildRequest } from './build-protocol.ts';
|
||||
|
||||
@@ -34,6 +34,7 @@ function importedDecals(path: string | undefined): string | undefined {
|
||||
function build(request: BuildRequest): void {
|
||||
checkBuildLocation(request);
|
||||
const decalCache = importedDecals(request.decalCache);
|
||||
const decalIndexFiles = decalCache ? readPlayerDecalIndexFiles(decalCache) : undefined;
|
||||
const result = buildGameCopy({
|
||||
stock: readStockGameFiles(request.stockPath),
|
||||
patches: request.patches,
|
||||
@@ -41,6 +42,7 @@ function build(request: BuildRequest): void {
|
||||
port: request.port,
|
||||
multiVehiclePackIds: multiVehiclePackIds(request.dataPath, console.info),
|
||||
placeholderDecals: decalCache === undefined,
|
||||
...(decalIndexFiles ? { decalIndexFiles } : {}),
|
||||
hookLogging: request.hookLogging,
|
||||
});
|
||||
const unavailable = [...result.exePatches.failures, ...result.guiPatches.failures, ...result.nativeModules.failures];
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
},
|
||||
"decals": {
|
||||
"source": "Decal source",
|
||||
"hint": "Import the online game's cache/content folder. The client uses placeholder decals when no cache is available.",
|
||||
"hint": "Import the online game's cache/content (or cache) folder for cached decals and downloadable skins. Placeholder decals are used when no cache is available.",
|
||||
"choose": "Choose decal cache…",
|
||||
"useDefault": "Use placeholder decals",
|
||||
"importing": "Importing decal cache",
|
||||
@@ -341,8 +341,7 @@
|
||||
"country": "Country",
|
||||
"type": "Vehicle type",
|
||||
"actions": "Bulk actions",
|
||||
"research": "Research all",
|
||||
"purchase": "Grant regular vehicles",
|
||||
"purchase": "Research and buy all",
|
||||
"equipment": "Unlock modifications",
|
||||
"empty": "This client has no eligible research branches.",
|
||||
"rank": "Rank {{rank}}",
|
||||
@@ -463,6 +462,7 @@
|
||||
"tankBotRespawns": "AI tank respawns",
|
||||
"airBotRespawns": "AI aircraft respawns",
|
||||
"strikeUcavSpawnScore": "Strike UCAV spawn points",
|
||||
"nuclearEscalationStrategicBombers": "Nuclear Escalation stage-3 strategic bombers (B-52H / Tu-95M)",
|
||||
"silverLions": "Starting Silver Lions",
|
||||
"goldenEagles": "Starting Golden Eagles",
|
||||
"preferLineSuccessor": "Prefer the next vehicle in the line",
|
||||
@@ -494,7 +494,7 @@
|
||||
"appUpdates": "Launcher updates",
|
||||
"appUpdatesToggle": "Check for launcher updates at start",
|
||||
"patchPacks": "Adaptation pack updates",
|
||||
"patchPacksHint": "After a game update, the patches for the new version are released on GitHub as an adaptation pack.",
|
||||
"patchPacksHint": "After a game update, patches for the new version are released as an adaptation pack.",
|
||||
"updateMirror": "Update mirror repository",
|
||||
"updateMirrorHint": "Enter an HTTPS mirror with a GitHub-compatible releases list. It is used if the primary source is unreachable. Leave blank to disable it.",
|
||||
"updateMirrorInvalid": "Enter a valid HTTPS repository address or leave the field blank.",
|
||||
@@ -666,6 +666,7 @@
|
||||
"J-Ground arcade and realistic": "Ground battles (arcade, realistic)",
|
||||
"J-Air arcade and realistic": "Air battles (arcade, realistic)",
|
||||
"J-Naval arcade and realistic": "Naval battles (arcade, realistic)",
|
||||
"E-Crew skills in battle": "Crew skills and qualifications in battle",
|
||||
"J-Sub-modes": "Additional modes (such as night battles)",
|
||||
"K-AI opponents and teammates": "AI opponents and allies",
|
||||
"K-Spawn score and respawns": "Spawn points and respawning",
|
||||
@@ -705,7 +706,7 @@
|
||||
"copy_not_found": "The selected client is no longer available.",
|
||||
"copies_write_failed": "The client registry could not be saved.",
|
||||
"copy_location_in_use": "The client or data location overlaps an existing client.",
|
||||
"decal_source_invalid": "The selected folder does not contain a usable decal cache.",
|
||||
"decal_source_invalid": "The selected folder does not contain a usable decal cache. Log into the online hangar once to populate it, then choose cache/content (or cache).",
|
||||
"decal_import_failed": "The decal cache could not be imported into the client's data folder. See the launcher log.",
|
||||
"maintenance_busy": "Maintenance requires the game, local server and other client operations to be stopped.",
|
||||
"maintenance_location": "The operation would affect files outside the registered client or data folder.",
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
},
|
||||
"decals": {
|
||||
"source": "贴花来源",
|
||||
"hint": "可导入在线版游戏的 cache/content。未导入时使用占位贴花。",
|
||||
"hint": "可导入在线版游戏的 cache/content(或 cache),同时支持已缓存的真实贴花与可下载涂装。未导入时使用占位贴花。",
|
||||
"choose": "选择贴花缓存…",
|
||||
"useDefault": "使用占位贴花",
|
||||
"importing": "正在导入贴花缓存",
|
||||
@@ -341,8 +341,7 @@
|
||||
"country": "国家",
|
||||
"type": "兵种",
|
||||
"actions": "批量操作",
|
||||
"research": "全部研发",
|
||||
"purchase": "获得常规载具",
|
||||
"purchase": "全部研发并购买",
|
||||
"equipment": "解锁改装件",
|
||||
"empty": "此客户端没有可编辑的研发分支。",
|
||||
"rank": "等级 {{rank}}",
|
||||
@@ -463,6 +462,7 @@
|
||||
"tankBotRespawns": "AI 坦克重生次数",
|
||||
"airBotRespawns": "AI 飞机重生次数",
|
||||
"strikeUcavSpawnScore": "打击无人机所需出生点数",
|
||||
"nuclearEscalationStrategicBombers": "核战冲突启用第 3 阶段战略核轰炸机(B-52H / Tu-95M)",
|
||||
"silverLions": "初始银狮",
|
||||
"goldenEagles": "初始金鹰",
|
||||
"preferLineSuccessor": "优先研发同系载具",
|
||||
@@ -494,7 +494,7 @@
|
||||
"appUpdates": "启动器本体更新",
|
||||
"appUpdatesToggle": "启动时检查本体更新",
|
||||
"patchPacks": "适配包更新",
|
||||
"patchPacksHint": "游戏更新后,新版本的补丁会以适配包的形式发布在 GitHub 上。",
|
||||
"patchPacksHint": "游戏更新后,新版本的补丁会以适配包的形式发布。",
|
||||
"updateMirror": "备用更新仓库",
|
||||
"updateMirrorHint": "填写支持 GitHub Releases 格式的 HTTPS 镜像地址。主源连接失败时使用,留空关闭。",
|
||||
"updateMirrorInvalid": "请输入有效的 HTTPS 仓库地址,或留空。",
|
||||
@@ -666,6 +666,7 @@
|
||||
"J-Ground arcade and realistic": "陆战(街机、历史)",
|
||||
"J-Air arcade and realistic": "空战(街机、历史)",
|
||||
"J-Naval arcade and realistic": "海战(街机、历史)",
|
||||
"E-Crew skills in battle": "战局乘员技能与资格",
|
||||
"J-Sub-modes": "附加模式(如夜战)",
|
||||
"K-AI opponents and teammates": "AI 对手与队友",
|
||||
"K-Spawn score and respawns": "出生点数与重生",
|
||||
@@ -705,7 +706,7 @@
|
||||
"copy_not_found": "所选客户端已不可用。",
|
||||
"copies_write_failed": "无法保存客户端记录。",
|
||||
"copy_location_in_use": "客户端位置或数据目录与已有客户端重叠。",
|
||||
"decal_source_invalid": "选定的目录缺少有效的贴花缓存。",
|
||||
"decal_source_invalid": "选定的目录缺少有效的贴花缓存。请先登录过在线版机库生成缓存,再选择在线版目录中的 cache/content(或 cache)。",
|
||||
"decal_import_failed": "无法把贴花缓存导入客户端数据目录。请查看启动器日志。",
|
||||
"maintenance_busy": "维护前需结束游戏、本地服务器和其他客户端操作。",
|
||||
"maintenance_location": "操作会影响登记的客户端或数据目录之外的文件。",
|
||||
|
||||
@@ -11,7 +11,7 @@ interface Props {
|
||||
readonly onError: (error: unknown) => void;
|
||||
}
|
||||
|
||||
const ACTIONS = ['research', 'purchase', 'equipment'] as const;
|
||||
const ACTIONS = ['purchase', 'equipment'] as const;
|
||||
|
||||
export function SaveResearch({ copyId, userId, readOnly, onError }: Props) {
|
||||
const { t, i18n } = useTranslation();
|
||||
|
||||
@@ -11,7 +11,7 @@ type Field = keyof TuningValues;
|
||||
type Draft = Partial<Record<Field, string | boolean>>;
|
||||
const fields = {
|
||||
rewards: ['rewardMultiplierSilverLions', 'rewardMultiplierResearchPoints', 'friendlyKillPenaltyMul'],
|
||||
battle: ['maxPlayers', 'smallTeamsMaxPlayers', 'brSpreadMrank', 'subModeChance', 'tankBotRespawns', 'airBotRespawns', 'strikeUcavSpawnScore'],
|
||||
battle: ['maxPlayers', 'smallTeamsMaxPlayers', 'brSpreadMrank', 'subModeChance', 'tankBotRespawns', 'airBotRespawns', 'strikeUcavSpawnScore', 'nuclearEscalationStrategicBombers'],
|
||||
newProfile: ['silverLions', 'goldenEagles'],
|
||||
research: ['preferLineSuccessor', 'autoTargetPick'],
|
||||
} as const satisfies Record<TuningSection, readonly Field[]>;
|
||||
@@ -70,7 +70,7 @@ export function TuningPage({ copy, section, onError }: Props) {
|
||||
const editor = (field: Field): ReactNode => {
|
||||
const active = draft[field] ?? inputValue(field, loaded.effective[field]);
|
||||
const label = t(`tuning.fields.${field}`);
|
||||
if (field === 'preferLineSuccessor') {
|
||||
if (typeof loaded.defaults[field] === 'boolean') {
|
||||
return <input type="checkbox" aria-label={label} disabled={saving} checked={active === true} onChange={(event) => set(field, event.target.checked)} />;
|
||||
}
|
||||
if (field === 'autoTargetPick') {
|
||||
|
||||
@@ -94,7 +94,7 @@ export const OfficialPreviewSchema = z.object({
|
||||
omitted: z.array(z.string()),
|
||||
});
|
||||
export const ResearchBranchSchema = z.object({ country: z.string().min(1), type: z.string().min(1) });
|
||||
export const ResearchOperationSchema = z.enum(['research', 'purchase', 'equipment']);
|
||||
export const ResearchOperationSchema = z.enum(['purchase', 'equipment']);
|
||||
export const SaveResearchSchema = z.object({
|
||||
branches: z.array(ResearchBranchSchema),
|
||||
selected: ResearchBranchSchema.nullable(),
|
||||
|
||||
@@ -12,6 +12,7 @@ export const TuningValuesSchema = z.object({
|
||||
tankBotRespawns: z.number().int().min(1).max(10),
|
||||
airBotRespawns: z.number().int().min(1).max(10),
|
||||
strikeUcavSpawnScore: z.number().int().min(1).max(10000),
|
||||
nuclearEscalationStrategicBombers: z.boolean(),
|
||||
silverLions: z.number().int().nonnegative(),
|
||||
goldenEagles: z.number().int().min(0).max(0x7fffffff),
|
||||
preferLineSuccessor: z.boolean(),
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
import { randomInt } from 'node:crypto';
|
||||
import type {
|
||||
BattleSpawnRulesData,
|
||||
NuclearCarrierUnit,
|
||||
RandomSpawnGroup,
|
||||
RandomSpawnUnit,
|
||||
SupportPlanePreset,
|
||||
@@ -43,6 +44,8 @@ export interface ExtraBattleSlot {
|
||||
/** The modifications enabled when not `allModifications`; the unit is otherwise stock. */
|
||||
readonly modifications: readonly string[];
|
||||
readonly forceWeapon?: string;
|
||||
/** Restricts the respawn weapon dropdown to these presets when multiple mode presets exist. */
|
||||
readonly allowedWeapons?: readonly string[];
|
||||
/** The RandomSpawnUnits group the vehicle was drawn from. */
|
||||
readonly groupName?: string;
|
||||
}
|
||||
@@ -56,7 +59,10 @@ export interface ExtraBattleSlotsInput {
|
||||
readonly sessionMaxMrank: number;
|
||||
readonly vehiclesByName: ReadonlyMap<string, CatalogueVehicle>;
|
||||
readonly rules: BattleSpawnRulesData;
|
||||
readonly tuning: Pick<BattleTuning, 'strikeUcavModes' | 'strikeUcavSessionMrankAllowance' | 'strikeUcavSpawnScore'>;
|
||||
readonly tuning: Pick<
|
||||
BattleTuning,
|
||||
'strikeUcavModes' | 'strikeUcavSessionMrankAllowance' | 'strikeUcavSpawnScore' | 'nuclearEscalationStrategicBombers'
|
||||
>;
|
||||
}
|
||||
|
||||
export function selectExtraBattleSlots(input: ExtraBattleSlotsInput): readonly ExtraBattleSlot[] {
|
||||
@@ -68,6 +74,7 @@ export function selectExtraBattleSlots(input: ExtraBattleSlotsInput): readonly E
|
||||
if (supportPlane) supportSlots.push(supportPlane);
|
||||
const ucav = strikeUcavSlot(input);
|
||||
if (ucav) supportSlots.push(ucav);
|
||||
supportSlots.push(...nuclearEscalationSlots(input));
|
||||
|
||||
// Keep room for fixed support vehicles while displaying random vehicle groups first.
|
||||
const slots: ExtraBattleSlot[] = [];
|
||||
@@ -118,6 +125,72 @@ function strikeUcavSlot(input: ExtraBattleSlotsInput): ExtraBattleSlot | undefin
|
||||
};
|
||||
}
|
||||
|
||||
const NUCLEAR_ESCALATION_TAG_PREFIX = 'nuclear_escalation_';
|
||||
const GROUND_RB_SUPPORT_MODE = 'tank_event_in_random_battles_historical';
|
||||
const EASTERN_STRATEGIC_BOMBER_COUNTRIES = new Set(['country_ussr', 'country_china']);
|
||||
|
||||
function nuclearEscalationSlots(input: ExtraBattleSlotsInput): ExtraBattleSlot[] {
|
||||
if (!input.declaration.tag?.startsWith(NUCLEAR_ESCALATION_TAG_PREFIX)) return [];
|
||||
const slots: ExtraBattleSlot[] = [];
|
||||
const tactical = selectTacticalNuclearCarrier(input);
|
||||
if (tactical) {
|
||||
const weaponNames = tactical.weapons.map((weapon) => weapon.name);
|
||||
slots.push({
|
||||
unitName: tactical.unitName,
|
||||
allModifications: true,
|
||||
modifications: [],
|
||||
...(weaponNames.length === 1 ? { forceWeapon: weaponNames[0]! } : { allowedWeapons: weaponNames }),
|
||||
});
|
||||
}
|
||||
if (input.tuning.nuclearEscalationStrategicBombers) {
|
||||
const strategic = selectStrategicNuclearBomber(input.country, input.rules.nuclearEscalationStrategicBombers);
|
||||
if (strategic) {
|
||||
const weapon = strategic.weapons[0];
|
||||
slots.push({
|
||||
unitName: strategic.unitName,
|
||||
allModifications: true,
|
||||
modifications: [],
|
||||
...(weapon ? { forceWeapon: weapon.name } : {}),
|
||||
});
|
||||
}
|
||||
}
|
||||
return slots;
|
||||
}
|
||||
|
||||
function selectTacticalNuclearCarrier(input: ExtraBattleSlotsInput): NuclearCarrierUnit | undefined {
|
||||
const byCountry = input.rules.nuclearEscalationTacticalCarriers.filter((entry) => entry.country === input.country);
|
||||
if (byCountry.length === 0) return undefined;
|
||||
|
||||
// Prefer the stock Ground RB nuclear carrier for the matching rank bracket when it carries
|
||||
// Nuclear Escalation 5 kt / 30 kt presets; otherwise pick the country's closest-mrank carrier.
|
||||
const groundPresets = input.rules.supportPlanes[GROUND_RB_SUPPORT_MODE] ?? [];
|
||||
const bracket = groundPresets.find((p) => input.sessionMaxMrank >= p.minMrank && input.sessionMaxMrank <= p.maxMrank);
|
||||
const preferredUnit = bracket?.units[input.country]?.unitName;
|
||||
if (preferredUnit) {
|
||||
const matched = byCountry.find((entry) => entry.unitName === preferredUnit);
|
||||
if (matched) return matched;
|
||||
}
|
||||
|
||||
return [...byCountry].sort((a, b) => {
|
||||
const distA = Math.abs(a.mrank - input.sessionMaxMrank);
|
||||
const distB = Math.abs(b.mrank - input.sessionMaxMrank);
|
||||
if (distA !== distB) return distA - distB;
|
||||
const underA = a.mrank <= input.sessionMaxMrank ? 0 : 1;
|
||||
const underB = b.mrank <= input.sessionMaxMrank ? 0 : 1;
|
||||
if (underA !== underB) return underA - underB;
|
||||
return a.mrank - b.mrank || a.unitName.localeCompare(b.unitName);
|
||||
})[0];
|
||||
}
|
||||
|
||||
function selectStrategicNuclearBomber(
|
||||
country: string,
|
||||
bombers: readonly NuclearCarrierUnit[],
|
||||
): NuclearCarrierUnit | undefined {
|
||||
if (bombers.length === 0) return undefined;
|
||||
const preferredCountry = EASTERN_STRATEGIC_BOMBER_COUNTRIES.has(country) ? 'country_ussr' : 'country_usa';
|
||||
return bombers.find((entry) => entry.country === preferredCountry) ?? bombers[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* The options of one random group: the group's vehicles inside `randomWindow`, or, when none fits,
|
||||
* those of the highest rank below it. Vehicles already in the lineup are left out (offline
|
||||
|
||||
@@ -10,7 +10,7 @@ import type { BattleSpawnRulesData } from '../game-data/datasets/battle-spawn-ru
|
||||
import type { MissionHeader } from '../game-data/datasets/multiplayer-missions.ts';
|
||||
import type { CatalogueVehicle } from '../game-data/datasets/vehicle-catalogue.ts';
|
||||
import type { GameModes, OfferedGameMode } from '../game-modes/game-modes.ts';
|
||||
import { MISSION_DIFFICULTY, SINGLE_SPAWN } from '../game-modes/mode-definition.ts';
|
||||
import { MISSION_DIFFICULTY, SINGLE_SPAWN, modeMaxRespawns } from '../game-modes/mode-definition.ts';
|
||||
import { serverTimeNow, serverTimeToUnixSeconds } from '../profile/server-time.ts';
|
||||
import { selectBattleCoalitions, type CoalitionPairing } from './battle-coalitions.ts';
|
||||
import { selectExtraBattleSlots, type ExtraBattleSlot } from './battle-extra-slots.ts';
|
||||
@@ -47,10 +47,12 @@ export interface BattleLaunchPlan {
|
||||
readonly sessionId: string;
|
||||
readonly modeId: number;
|
||||
readonly modeName: string;
|
||||
readonly modeTag?: string;
|
||||
readonly economicName: string;
|
||||
readonly missionName: string;
|
||||
/** The mission as the game describes it, including the parameters copied into the mission settings. */
|
||||
readonly mission: MissionHeader;
|
||||
readonly missionRuleKeys: readonly string[];
|
||||
readonly missionFile: string;
|
||||
readonly missionType: string;
|
||||
readonly level?: string;
|
||||
@@ -68,6 +70,7 @@ export interface BattleLaunchPlan {
|
||||
readonly maxMrank: number;
|
||||
readonly maxPlayers: number;
|
||||
readonly maxBots: number;
|
||||
readonly maxRespawns?: number;
|
||||
readonly tankBotRespawns: number;
|
||||
readonly airBotRespawns: number;
|
||||
readonly useTankBots: boolean;
|
||||
@@ -164,7 +167,7 @@ export class BattleMatchmaker {
|
||||
const pool = candidates.filter((mode) => isModeEligibleForLineup(
|
||||
mode.declaration, input.slotVehicles, input.selectedSlot?.unitName, this.#vehiclesByName, input.mrankDeltas,
|
||||
));
|
||||
if (pool.length === 0) return candidates.find((mode) => mode.declaration.multiSlot !== false);
|
||||
if (pool.length === 0) return undefined;
|
||||
const classics = pool.filter((mode) => !mode.declaration.tag);
|
||||
const subModes = pool.filter((mode) => Boolean(mode.declaration.tag));
|
||||
if (subModes.length > 0 && classics.length > 0) {
|
||||
@@ -189,12 +192,14 @@ export class BattleMatchmaker {
|
||||
const desiredPlayers = declaration.isSmallTeams ? this.#tuning.smallTeamsMaxPlayers : this.#tuning.maxPlayers;
|
||||
const maxPlayers = Math.min(desiredPlayers, maxSlotsForMission(mission, desiredPlayers));
|
||||
const maxBots = Math.min(this.#tuning.maxBots, Math.max(1, maxPlayers - 1));
|
||||
const maxRespawns = modeMaxRespawns(declaration);
|
||||
const missionLocName = resolveMissionLocName(mission);
|
||||
const environment = declaration.environmentOverride ?? mission.environment;
|
||||
const session = this.#sessions.create({
|
||||
userId: input.userId,
|
||||
modeId: declaration.gameModeId,
|
||||
modeName: declaration.name,
|
||||
...(declaration.tag !== undefined ? { modeTag: declaration.tag } : {}),
|
||||
economicName: declaration.economicName,
|
||||
difficulty: declaration.difficulty,
|
||||
requiredClass: declaration.requiredClass,
|
||||
@@ -221,9 +226,11 @@ export class BattleMatchmaker {
|
||||
sessionId: session.sessionId,
|
||||
modeId: declaration.gameModeId,
|
||||
modeName: declaration.name,
|
||||
...(declaration.tag !== undefined ? { modeTag: declaration.tag } : {}),
|
||||
economicName: declaration.economicName,
|
||||
missionName: mission.name,
|
||||
mission,
|
||||
missionRuleKeys: declaration.missionRuleKeys ?? [],
|
||||
missionFile: mission.path,
|
||||
missionType: mission.type ?? 'domination',
|
||||
...(mission.level !== undefined ? { level: mission.level } : {}),
|
||||
@@ -241,6 +248,7 @@ export class BattleMatchmaker {
|
||||
maxMrank,
|
||||
maxPlayers,
|
||||
maxBots,
|
||||
...(maxRespawns === undefined ? {} : { maxRespawns }),
|
||||
tankBotRespawns: this.#tuning.tankBotRespawns,
|
||||
airBotRespawns: declaration.multiSlot === false ? SINGLE_SPAWN : this.#tuning.airBotRespawns,
|
||||
useTankBots: allowedSet.has('tank'),
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
* copied here from the mission file, base values first and then the sub-block for the battle's
|
||||
* difficulty. `_gameMode` is left to the client, which takes it from its own native constants.
|
||||
*/
|
||||
import { emptyBlock, ensureBlock, setParam, appendParam, type BlkBlock, type BlkParam, type BlkValue } from '@wto/blk';
|
||||
import { SINGLE_SPAWN } from '../game-modes/mode-definition.ts';
|
||||
import { emptyBlock, ensureBlock, findParam, setParam, appendParam, type BlkBlock, type BlkParam, type BlkValue } from '@wto/blk';
|
||||
import { UNLIMITED_RESPAWNS } from '../game-modes/mode-definition.ts';
|
||||
import type { ExtraBattleSlot } from './battle-extra-slots.ts';
|
||||
import type { BattleLaunchPlan } from './battle-matchmaker.ts';
|
||||
import type { CustomBotsPool } from './battle-ranks.ts';
|
||||
@@ -23,6 +23,7 @@ const RULE_KEYS: readonly string[] = [
|
||||
'scoreLimit', 'timeLimit', 'killLimit', 'deathPenaltyMul',
|
||||
'ctaCaptureZoneEqualPenaltyMul', 'ctaCaptureZonePenaltyMul', 'captureZonePenaltyMul', 'scorePerSec',
|
||||
'ctaInstantDecreaseTicketsWhenNoRespawn', 'randomSpawnTeams', 'remapAiTankModels', 'useAlternativeMapCoord',
|
||||
'allowedKillStreaks',
|
||||
];
|
||||
|
||||
/** Game type switches of a versus battle with tickets, capture zones and session rewards. */
|
||||
@@ -39,6 +40,13 @@ const VERSUS_SWITCHES: readonly string[] = [
|
||||
export function battleMissionSettings(plan: BattleLaunchPlan, scores: Readonly<Record<string, number>>): BlkBlock {
|
||||
const settings = emptyBlock();
|
||||
copyMissionParams(settings, plan);
|
||||
// Enable Ground Arcade air events when the mission allows killstreaks; the LocalMP host preserves
|
||||
// MissionSettings.useKillStreaks across prepare_local_mission (local_mp_air_events.c).
|
||||
const allowedKillStreaks = findParam(settings, 'allowedKillStreaks')?.value;
|
||||
if (plan.modeName === 'tank_event_in_random_battles_arcade'
|
||||
&& allowedKillStreaks?.type === 'bool' && allowedKillStreaks.value) {
|
||||
setParam(settings, 'useKillStreaks', flag(true));
|
||||
}
|
||||
if (plan.level !== undefined) setParam(settings, 'level', text(plan.level));
|
||||
if (plan.environment !== undefined) setParam(settings, 'environment', text(plan.environment));
|
||||
if (plan.weather !== undefined) setParam(settings, 'weather', text(plan.weather));
|
||||
@@ -62,9 +70,11 @@ export function battleMissionSettings(plan: BattleLaunchPlan, scores: Readonly<R
|
||||
for (const name of VERSUS_SWITCHES) setParam(settings, name, flag(true));
|
||||
// The native in-flight rearm request and its receiver both require unlimited reserve ammunition.
|
||||
setParam(settings, 'isLimitedAmmo', flag(plan.modeName !== 'air_arcade'));
|
||||
setParam(settings, 'allowSpare', flag(!plan.selectedSlot));
|
||||
// MissionSettings defaults isLimitedFuel to false, which disables fuel consumption and HUD timers.
|
||||
setParam(settings, 'isLimitedFuel', flag(true));
|
||||
setParam(settings, 'allowSpare', flag(!plan.selectedSlot && plan.maxRespawns !== UNLIMITED_RESPAWNS));
|
||||
if (plan.maxRespawns !== undefined) setParam(settings, 'maxRespawns', integer(plan.maxRespawns));
|
||||
if (plan.selectedSlot) {
|
||||
setParam(settings, 'maxRespawns', integer(SINGLE_SPAWN));
|
||||
setParam(settings, 'ctaInstantDecreaseTicketsWhenNoRespawn', flag(true));
|
||||
// The native mission loader reads the AI limit at the top level, after its bots.blk default.
|
||||
setParam(settings, 'numBotRespawns', integer(plan.airBotRespawns));
|
||||
@@ -90,14 +100,15 @@ export function battleMissionSettings(plan: BattleLaunchPlan, scores: Readonly<R
|
||||
}
|
||||
|
||||
function copyMissionParams(settings: BlkBlock, plan: BattleLaunchPlan): void {
|
||||
const wanted = new Set([...LOCALIZATION_KEYS, ...RULE_KEYS]);
|
||||
const ruleKeys = new Set([...RULE_KEYS, ...plan.missionRuleKeys]);
|
||||
const wanted = new Set([...LOCALIZATION_KEYS, ...ruleKeys]);
|
||||
const copy = (params: readonly BlkParam[] | undefined, keys: ReadonlySet<string>): void => {
|
||||
for (const param of params ?? []) {
|
||||
if (keys.has(param.name)) setParam(settings, param.name, param.value);
|
||||
}
|
||||
};
|
||||
copy(plan.mission.missionParams, wanted);
|
||||
copy(plan.mission.difficultyParams[plan.difficulty], new Set(RULE_KEYS));
|
||||
copy(plan.mission.difficultyParams[plan.difficulty], ruleKeys);
|
||||
}
|
||||
|
||||
/** Fixed spawn costs of extra slots, read back by the spawn score respondents (customSpawnScore). */
|
||||
@@ -117,6 +128,7 @@ function customBotsBlock(plan: BattleLaunchPlan): BlkBlock {
|
||||
setParam(bots, 'wtoPlayerTeam', text(String(plan.playerTeam)));
|
||||
setParam(bots, 'wtoTeamACountries', text(plan.countriesAllies.join(';')));
|
||||
setParam(bots, 'wtoTeamBCountries', text(plan.countriesAxis.join(';')));
|
||||
if (plan.maxRespawns === UNLIMITED_RESPAWNS) setParam(bots, 'wtoUnlimitedRespawns', text('1'));
|
||||
setParam(bots, 'numBotRespawnsInMultiSlot', integer(plan.airBotRespawns));
|
||||
setParam(bots, 'numTankBotRespawnsInMultiSlot', integer(plan.tankBotRespawns));
|
||||
setParam(bots, 'numBotRespawnsInVersus', integer(plan.airBotRespawns));
|
||||
|
||||
@@ -26,6 +26,7 @@ export interface BattleTuning {
|
||||
readonly strikeUcavSpawnScore: number;
|
||||
readonly tankBotRespawns: number;
|
||||
readonly airBotRespawns: number;
|
||||
readonly nuclearEscalationStrategicBombers: boolean;
|
||||
}
|
||||
|
||||
export function readBattleTuning(reader: TuningReader): BattleTuning {
|
||||
@@ -66,5 +67,6 @@ export function readBattleTuning(reader: TuningReader): BattleTuning {
|
||||
strikeUcavSpawnScore: reader.int('strikeUcavSpawnScore', { min: 1, max: 10000 }),
|
||||
tankBotRespawns: reader.int('tankBotRespawns', { min: 1, max: 10 }),
|
||||
airBotRespawns: reader.int('airBotRespawns', { min: 1, max: 10 }),
|
||||
nuclearEscalationStrategicBombers: reader.bool('nuclearEscalationStrategicBombers'),
|
||||
};
|
||||
}
|
||||
@@ -14,12 +14,14 @@
|
||||
* char.vromfs.bin config/wpcost.blk
|
||||
* ucav_*_killstreak{ country:t ... }
|
||||
* The strike UCAVs, one per country.
|
||||
* *_killstreak / nt_* with weapons.<preset>.totalNuclearYield:i
|
||||
* Tactical (5 kt / 30 kt) and strategic (>= 1000 kt) nuclear carriers for Nuclear Escalation.
|
||||
* char.vromfs.bin config/warpoints.blk respawn_points / TankHistorical
|
||||
* Starting points and unit cost parameters for Ground Realistic Battles.
|
||||
*/
|
||||
import type { BlkBlock } from '@wto/blk';
|
||||
import { findParam } from '@wto/blk';
|
||||
import { blockAt, numberField, stringField, stringList } from './blk-fields.ts';
|
||||
import { blockAt, boolField, numberField, stringField, stringList } from './blk-fields.ts';
|
||||
import type { Dataset } from './dataset.ts';
|
||||
|
||||
export interface SupportPlaneUnit {
|
||||
@@ -43,6 +45,18 @@ export interface StrikeUcav {
|
||||
readonly unitName: string;
|
||||
}
|
||||
|
||||
export interface NuclearCarrierWeapon {
|
||||
readonly name: string;
|
||||
readonly yieldKt: number;
|
||||
}
|
||||
|
||||
export interface NuclearCarrierUnit {
|
||||
readonly country: string;
|
||||
readonly unitName: string;
|
||||
readonly mrank: number;
|
||||
readonly weapons: readonly NuclearCarrierWeapon[];
|
||||
}
|
||||
|
||||
export interface RandomSpawnUnit {
|
||||
readonly unitName: string;
|
||||
readonly addModifications: readonly string[];
|
||||
@@ -76,22 +90,31 @@ export interface BattleSpawnRulesData {
|
||||
/** By event name (`missionSupportPlane` keys are game mode names). */
|
||||
readonly supportPlanes: Readonly<Record<string, readonly SupportPlanePreset[]>>;
|
||||
readonly strikeUcavs: readonly StrikeUcav[];
|
||||
/** Killstreak nuclear carriers carrying 5 kt / 30 kt Nuclear Escalation presets. */
|
||||
readonly nuclearEscalationTacticalCarriers: readonly NuclearCarrierUnit[];
|
||||
/** Megaton-class strategic nuclear bombers (`nt_*` with totalNuclearYield >= 1000 kt). */
|
||||
readonly nuclearEscalationStrategicBombers: readonly NuclearCarrierUnit[];
|
||||
readonly spawnScore: SpawnScoreRules;
|
||||
/** By event economic name, then country. */
|
||||
readonly randomSpawnUnits: Readonly<Record<string, Readonly<Record<string, readonly RandomSpawnGroup[]>>>>;
|
||||
}
|
||||
|
||||
const STRIKE_UCAV_PATTERN = /^ucav_.*_killstreak$/;
|
||||
const KILLSTREAK_PATTERN = /_killstreak$/;
|
||||
const STRATEGIC_BOMBER_PATTERN = /^nt_/;
|
||||
const STRATEGIC_YIELD_MIN_KT = 1000;
|
||||
|
||||
export const battleSpawnRules: Dataset<BattleSpawnRulesData> = {
|
||||
id: 'battle-spawn-rules',
|
||||
version: 3,
|
||||
version: 4,
|
||||
extract: (source) => {
|
||||
const gameplay = source.readBlk('aces.vromfs.bin', 'config/gameplay.blk');
|
||||
const wpcost = source.readBlk('char.vromfs.bin', 'config/wpcost.blk');
|
||||
return {
|
||||
supportPlanes: extractSupportPlanes(blockAt(gameplay, 'missionSupportPlane')),
|
||||
strikeUcavs: extractStrikeUcavs(wpcost.blocks),
|
||||
nuclearEscalationTacticalCarriers: extractNuclearCarriers(wpcost.blocks, 'tactical'),
|
||||
nuclearEscalationStrategicBombers: extractNuclearCarriers(wpcost.blocks, 'strategic'),
|
||||
spawnScore: extractSpawnScore(blockAt(source.readBlk('char.vromfs.bin', 'config/warpoints.blk'), 'respawn_points')),
|
||||
randomSpawnUnits: extractRandomSpawnUnits(blockAt(gameplay, 'RandomSpawnUnits')),
|
||||
};
|
||||
@@ -162,6 +185,38 @@ function extractStrikeUcavs(wpcostBlocks: readonly BlkBlock[]): StrikeUcav[] {
|
||||
});
|
||||
}
|
||||
|
||||
function extractNuclearCarriers(
|
||||
wpcostBlocks: readonly BlkBlock[],
|
||||
kind: 'tactical' | 'strategic',
|
||||
): NuclearCarrierUnit[] {
|
||||
const carriers: NuclearCarrierUnit[] = [];
|
||||
for (const unitBlk of wpcostBlocks) {
|
||||
const country = stringField(unitBlk, 'country') ?? '';
|
||||
if (!country.startsWith('country_')) continue;
|
||||
if (kind === 'tactical' && !KILLSTREAK_PATTERN.test(unitBlk.name)) continue;
|
||||
if (kind === 'strategic' && !STRATEGIC_BOMBER_PATTERN.test(unitBlk.name)) continue;
|
||||
const weaponsBlk = blockAt(unitBlk, 'weapons');
|
||||
if (!weaponsBlk) continue;
|
||||
const weapons: NuclearCarrierWeapon[] = [];
|
||||
for (const weaponBlk of weaponsBlk.blocks) {
|
||||
if (boolField(weaponBlk, 'isWeaponForCustomSlot') === true) continue;
|
||||
if (boolField(weaponBlk, 'hideInGui') === true) continue;
|
||||
if (weaponBlk.name.includes('without_countermeasures')) continue;
|
||||
const yieldKt = numberField(weaponBlk, 'totalNuclearYield') ?? 0;
|
||||
if (yieldKt <= 0) continue;
|
||||
if (kind === 'tactical' && yieldKt >= STRATEGIC_YIELD_MIN_KT) continue;
|
||||
if (kind === 'strategic' && yieldKt < STRATEGIC_YIELD_MIN_KT) continue;
|
||||
weapons.push({ name: weaponBlk.name, yieldKt });
|
||||
}
|
||||
if (weapons.length === 0) continue;
|
||||
weapons.sort((a, b) => a.yieldKt - b.yieldKt || a.name.localeCompare(b.name));
|
||||
const mrank = numberField(unitBlk, 'economicRankHistorical') ?? numberField(unitBlk, 'economicRank') ?? 0;
|
||||
carriers.push({ country, unitName: unitBlk.name, mrank, weapons });
|
||||
}
|
||||
carriers.sort((a, b) => a.country.localeCompare(b.country) || a.mrank - b.mrank || a.unitName.localeCompare(b.unitName));
|
||||
return carriers;
|
||||
}
|
||||
|
||||
function extractRandomSpawnUnits(
|
||||
root: BlkBlock | undefined,
|
||||
): Record<string, Record<string, RandomSpawnGroup[]>> {
|
||||
|
||||
@@ -50,6 +50,10 @@ export interface GameModeDeclaration {
|
||||
* `true`; `false` for single-slot modes (`air_realistic` and its `small_teams_` sub-mode).
|
||||
*/
|
||||
readonly multiSlot?: boolean;
|
||||
/** Stock maxRespawns value when this mode specifies its own respawn count. */
|
||||
readonly maxRespawns?: number;
|
||||
/** Additional scalar settings the local host needs from this mode's missions. */
|
||||
readonly missionRuleKeys?: readonly string[];
|
||||
/** False for modes whose native weapon rules replace combat presets. Defaults to true. */
|
||||
readonly allowBotAircraftLoadouts?: boolean;
|
||||
/** Minimum `mrank` exposed on the parent mode for Night Battles (`scripts/events/eventinfo.nut:134-136`). */
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
* AB/RB get Enduring Confrontation; Ground AB and Air AB get none);
|
||||
* - `queueEvent.nut` includes or excludes its `gameModeId` in `match.enqueue` `game_modes_list`.
|
||||
*/
|
||||
import { UNLIMITED_RESPAWNS } from '../mode-definition.ts';
|
||||
import type { GameModeDeclaration } from './game-mode-declaration.ts';
|
||||
import {
|
||||
AIR_REALISTIC_MISSIONS,
|
||||
@@ -69,6 +70,15 @@ export const SUB_GAME_MODES: readonly GameModeDeclaration[] = [
|
||||
displayType: 'random_battle',
|
||||
allowedCraftMinMrank: { aircraft: MIN_MRANK_NUCLEAR_ESCALATION },
|
||||
minQueueMrank: MIN_MRANK_NUCLEAR_ESCALATION,
|
||||
maxRespawns: UNLIMITED_RESPAWNS,
|
||||
// mission_settings.mission in mis.vromfs.bin gamedata/missions/cta/planes/nuclear_escalation/.
|
||||
missionRuleKeys: [
|
||||
'customHUD', 'nuclearEscalationStage1', 'nuclearEscalationStage2', 'nuclearEscalationStage3',
|
||||
'useSpawnDelay', 'afterRespawnDelaySec', 'overrideMaxActiveUnitsWeight', 'scheduleBasedGmUpdateMaxInterval',
|
||||
'disableFallingTrees', 'alwaysSendAllyGMData', 'isAlwaysShowCollectiveDetectedUnits', 'useAIForCollectiveDetection',
|
||||
'allowToChooseHUDIconPreset', 'showAIKilllog', 'showUnitTooltipOnMap', 'disableMfdForPrevgenConsoles',
|
||||
'clientReplayMaxSizeMb', 'timeToLoseInstantDetection', 'showTacticalMapCellSize',
|
||||
],
|
||||
requiredClass: 'aircraft',
|
||||
allowedClasses: ['aircraft'],
|
||||
missions: NUCLEAR_ESCALATION_MISSIONS,
|
||||
|
||||
@@ -41,8 +41,13 @@ export const MISSION_DIFFICULTY: Readonly<Record<ModeDifficulty, string>> = {
|
||||
simulator: 'hardcore',
|
||||
};
|
||||
|
||||
// globals/missions/respawnCountModes.nut: RESPAWN_COUNT_MODE.SINGLE_SPAWN.
|
||||
// globals/missions/respawnCountModes.nut: RESPAWN_COUNT_MODE.
|
||||
export const SINGLE_SPAWN = 1;
|
||||
export const UNLIMITED_RESPAWNS = -2;
|
||||
|
||||
export function modeMaxRespawns(mode: GameModeDeclaration): number | undefined {
|
||||
return mode.maxRespawns ?? (mode.multiSlot === false ? SINGLE_SPAWN : undefined);
|
||||
}
|
||||
|
||||
export type ModeDefinition = Readonly<Record<string, unknown>>;
|
||||
|
||||
@@ -50,6 +55,7 @@ export function buildModeDefinition(mode: GameModeDeclaration, missions: readonl
|
||||
countries: readonly string[], missionRanks?: MissionRotationRanks): ModeDefinition {
|
||||
const minTeamSize = mode.teamSizeOverride?.min ?? 1;
|
||||
const maxTeamSize = mode.teamSizeOverride?.max ?? teamSize(mode, missions);
|
||||
const maxRespawns = modeMaxRespawns(mode);
|
||||
const team = {
|
||||
countries: [...countries],
|
||||
allowedCrafts: mode.allowedClasses.map((unitClass) => {
|
||||
@@ -83,7 +89,7 @@ export function buildModeDefinition(mode: GameModeDeclaration, missions: readonl
|
||||
teamB: structuredClone(team),
|
||||
mission_decl: {
|
||||
difficulty: MISSION_DIFFICULTY[mode.difficulty],
|
||||
...(mode.multiSlot === false ? { maxRespawns: SINGLE_SPAWN } : {}),
|
||||
...(maxRespawns === undefined ? {} : { maxRespawns }),
|
||||
missions_list: Object.fromEntries(missions.map((mission) => {
|
||||
const ranges = missionRanks?.byMission.get(mission.name);
|
||||
return [mission.name, ranges?.length === 1 ? { enableIf: ranges[0] } : {}];
|
||||
|
||||
@@ -16,7 +16,6 @@ import type { BlkBlock, BlkValue } from '@wto/blk';
|
||||
import type { BannerParams } from '../battle/battle-economy.ts';
|
||||
import type { BattleLaunchPlan } from '../battle/battle-matchmaker.ts';
|
||||
import { battleMissionSettings } from '../battle/battle-mission-settings.ts';
|
||||
import { SINGLE_SPAWN } from '../game-modes/mode-definition.ts';
|
||||
|
||||
type WireParam = readonly [name: string, type: 't' | 'i' | 'r' | 'b', value: string | number | boolean];
|
||||
|
||||
@@ -52,12 +51,13 @@ export function battleLaunchNotify(
|
||||
mission: {
|
||||
name: plan.missionName,
|
||||
difficulty: plan.difficulty,
|
||||
...(plan.selectedSlot ? { maxRespawns: SINGLE_SPAWN } : {}),
|
||||
...(plan.maxRespawns === undefined ? {} : { maxRespawns: plan.maxRespawns }),
|
||||
},
|
||||
},
|
||||
battle: {
|
||||
sessionId: plan.sessionId,
|
||||
modeName: plan.modeName,
|
||||
...(plan.modeTag ? { modeTag: plan.modeTag } : {}),
|
||||
economicName: plan.economicName,
|
||||
country: plan.country,
|
||||
missionName: plan.missionName,
|
||||
|
||||
@@ -4,7 +4,12 @@
|
||||
* carry 30,000+ flat sub-blocks; indexing once drops refresh cost from O(N^2) to O(N).
|
||||
*/
|
||||
import { ensureBlock, findBlock, findParam, setParam, type BlkBlock, type BlkParam } from '@wto/blk';
|
||||
import { recordName, type ModificationRecord } from '../profile/profile-modifications.ts';
|
||||
import {
|
||||
allModificationBlocks,
|
||||
MAX_MODIFICATION_BLOCK_ENTRIES,
|
||||
recordName,
|
||||
type ModificationRecord,
|
||||
} from '../profile/profile-modifications.ts';
|
||||
import type { WeaponRecord } from '../profile/profile-weapons.ts';
|
||||
|
||||
const HANGAR = 'hangar';
|
||||
@@ -21,7 +26,7 @@ export class ProfileEquipmentIndex {
|
||||
readonly #weapons = new Map<string, BlkBlock>();
|
||||
readonly #modsResearch = new Map<string, BlkBlock>();
|
||||
readonly #removedResearch = new Set<string>();
|
||||
#modificationsBlock: BlkBlock | undefined;
|
||||
readonly #modificationsBlocks: BlkBlock[];
|
||||
#weaponsBlock: BlkBlock | undefined;
|
||||
#modsResearchBlock: BlkBlock | undefined;
|
||||
|
||||
@@ -30,9 +35,9 @@ export class ProfileEquipmentIndex {
|
||||
const hangar = findBlock(profile, HANGAR);
|
||||
if (hangar) for (const entry of hangar.blocks) this.#hangar.set(entry.name, entry);
|
||||
|
||||
this.#modificationsBlock = findBlock(profile, MODIFICATIONS);
|
||||
if (this.#modificationsBlock) {
|
||||
for (const entry of this.#modificationsBlock.blocks) this.#modifications.set(entry.name, entry);
|
||||
this.#modificationsBlocks = allModificationBlocks(profile);
|
||||
for (const chunk of this.#modificationsBlocks) {
|
||||
for (const entry of chunk.blocks) this.#modifications.set(entry.name, entry);
|
||||
}
|
||||
|
||||
this.#weaponsBlock = findBlock(profile, WEAPONS);
|
||||
@@ -103,14 +108,32 @@ export class ProfileEquipmentIndex {
|
||||
const key = recordName(vehicle, modification);
|
||||
let block = this.#modifications.get(key);
|
||||
if (!block) {
|
||||
this.#modificationsBlock ??= ensureBlock(this.#profile, MODIFICATIONS);
|
||||
block = { name: key, params: [], blocks: [] };
|
||||
this.#modificationsBlock.blocks.push(block);
|
||||
this.#appendModificationBlock(block);
|
||||
this.#modifications.set(key, block);
|
||||
}
|
||||
block.params = orderedModParams(record);
|
||||
}
|
||||
|
||||
#appendModificationBlock(entry: BlkBlock): void {
|
||||
for (let index = this.#modificationsBlocks.length - 1; index >= 0; index--) {
|
||||
const chunk = this.#modificationsBlocks[index]!;
|
||||
if (chunk.blocks.length < MAX_MODIFICATION_BLOCK_ENTRIES) {
|
||||
chunk.blocks.push(entry);
|
||||
return;
|
||||
}
|
||||
}
|
||||
const nextChunk: BlkBlock = { name: MODIFICATIONS, params: [], blocks: [entry] };
|
||||
const lastChunk = this.#modificationsBlocks[this.#modificationsBlocks.length - 1];
|
||||
if (lastChunk) {
|
||||
const insertAt = this.#profile.blocks.lastIndexOf(lastChunk) + 1;
|
||||
this.#profile.blocks.splice(insertAt, 0, nextChunk);
|
||||
} else {
|
||||
this.#profile.blocks.push(nextChunk);
|
||||
}
|
||||
this.#modificationsBlocks.push(nextChunk);
|
||||
}
|
||||
|
||||
weaponRecord(vehicle: string, weapon: string): WeaponRecord | undefined {
|
||||
const block = this.#weapons.get(`${vehicle}_${weapon}`);
|
||||
if (!block) return undefined;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
import { ensureBlock, findBlock, type BlkBlock } from '@wto/blk';
|
||||
import type { BattleSpawnRulesData } from '../game-data/datasets/battle-spawn-rules.ts';
|
||||
import { recordName } from '../profile/profile-modifications.ts';
|
||||
import { allModificationBlocks, appendModificationEntry, recordName } from '../profile/profile-modifications.ts';
|
||||
import type { EquipmentCatalogue } from './equipment-catalogue.ts';
|
||||
|
||||
export interface SupportPlaneModification {
|
||||
@@ -31,7 +31,10 @@ export interface SupportUnitEquipmentGrants {
|
||||
}
|
||||
|
||||
export function supportPlaneModifications(
|
||||
rules: Pick<BattleSpawnRulesData, 'supportPlanes' | 'strikeUcavs'>,
|
||||
rules: Pick<
|
||||
BattleSpawnRulesData,
|
||||
'supportPlanes' | 'strikeUcavs' | 'nuclearEscalationTacticalCarriers' | 'nuclearEscalationStrategicBombers'
|
||||
>,
|
||||
catalogue: EquipmentCatalogue,
|
||||
): SupportUnitEquipmentGrants {
|
||||
const seenMods = new Set<string>();
|
||||
@@ -53,21 +56,34 @@ export function supportPlaneModifications(
|
||||
weapons.push({ vehicle, weapon, count: Math.max(1, count) });
|
||||
};
|
||||
|
||||
const grantWeaponPreset = (unitName: string, weapon: string): void => {
|
||||
const facts = catalogue.weapon(unitName, weapon);
|
||||
addWeapon(unitName, weapon, facts?.maxCount ?? 1);
|
||||
for (const modification of facts?.requires ?? []) addMod(unitName, modification);
|
||||
for (const container of facts?.sumWeapons ?? []) {
|
||||
const containerFacts = catalogue.weapon(unitName, container);
|
||||
addWeapon(unitName, container, containerFacts?.maxCount ?? 1);
|
||||
for (const modification of containerFacts?.requires ?? []) addMod(unitName, modification);
|
||||
}
|
||||
};
|
||||
|
||||
for (const presets of Object.values(rules.supportPlanes)) {
|
||||
for (const preset of presets) {
|
||||
for (const { unitName, weapon } of Object.values(preset.units)) {
|
||||
const facts = catalogue.weapon(unitName, weapon);
|
||||
addWeapon(unitName, weapon, facts?.maxCount ?? 1);
|
||||
for (const modification of facts?.requires ?? []) addMod(unitName, modification);
|
||||
for (const container of facts?.sumWeapons ?? []) {
|
||||
const containerFacts = catalogue.weapon(unitName, container);
|
||||
addWeapon(unitName, container, containerFacts?.maxCount ?? 1);
|
||||
for (const modification of containerFacts?.requires ?? []) addMod(unitName, modification);
|
||||
}
|
||||
grantWeaponPreset(unitName, weapon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const carrier of [
|
||||
...rules.nuclearEscalationTacticalCarriers,
|
||||
...rules.nuclearEscalationStrategicBombers,
|
||||
]) {
|
||||
for (const weapon of carrier.weapons) {
|
||||
grantWeaponPreset(carrier.unitName, weapon.name);
|
||||
}
|
||||
}
|
||||
|
||||
for (const ucav of rules.strikeUcavs) {
|
||||
const vehicle = catalogue.vehicle(ucav.unitName);
|
||||
if (!vehicle) continue;
|
||||
@@ -82,13 +98,14 @@ export function supportPlaneModifications(
|
||||
|
||||
export function grantSupportPlaneModifications(profile: BlkBlock, grants: SupportUnitEquipmentGrants): void {
|
||||
if (grants.modifications.length > 0) {
|
||||
let modsBlock = findBlock(profile, 'modifications');
|
||||
const existing = new Set((modsBlock?.blocks ?? []).map((entry) => entry.name));
|
||||
const existing = new Set<string>();
|
||||
for (const chunk of allModificationBlocks(profile)) {
|
||||
for (const entry of chunk.blocks) existing.add(entry.name);
|
||||
}
|
||||
for (const { vehicle, modification } of grants.modifications) {
|
||||
const key = recordName(vehicle, modification);
|
||||
if (existing.has(key)) continue;
|
||||
modsBlock ??= ensureBlock(profile, 'modifications');
|
||||
modsBlock.blocks.push({ name: key, params: [{ name: 'count', value: { type: 'int64', value: 1n } }], blocks: [] });
|
||||
appendModificationEntry(profile, { name: key, params: [{ name: 'count', value: { type: 'int64', value: 1n } }], blocks: [] });
|
||||
existing.add(key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,11 +12,19 @@
|
||||
* the first one that does not match (aces.exe 0x942740), so a record is always rewritten whole:
|
||||
* wpSpent:i goldSpent:i lastWpCost:i lastGoldCost:i persist:b rpEarned:i enabled:b count:i64 modLevel:i
|
||||
* Absent values are left out; enabled is only written when false (the default is enabled).
|
||||
*
|
||||
* Dagor's binary DataBlock stores child block counts in a uint16 (65,535 max). Because the full
|
||||
* vehicle catalogue exceeds 65,535 modifications, aces.exe splits modifications across up to 3
|
||||
* sibling top-level `modifications` blocks of at most 65,535 entries each (2.61.0.37 0x938fae..0x9397e6,
|
||||
* 2.61.0.58 0x93ba70 / 0x93bb53). All readers and writers here span every sibling block.
|
||||
*/
|
||||
import { ensureBlock, findBlock, type BlkBlock, type BlkParam } from '@wto/blk';
|
||||
import type { BlkBlock, BlkParam } from '@wto/blk';
|
||||
|
||||
const MODIFICATIONS = 'modifications';
|
||||
|
||||
/** Maximum entries per `modifications` DataBlock (uint16 child count limit in aces.exe 0x939000 / 0x93ba70). */
|
||||
export const MAX_MODIFICATION_BLOCK_ENTRIES = 0xffff;
|
||||
|
||||
export interface ModificationRecord {
|
||||
readonly silverLionsSpent: number;
|
||||
readonly goldenEaglesSpent: number;
|
||||
@@ -29,9 +37,66 @@ export function recordName(vehicle: string, modification: string): string {
|
||||
return `${vehicle}_${modification}`;
|
||||
}
|
||||
|
||||
/** Every top-level `modifications` chunk in the profile, in document order. */
|
||||
export function allModificationBlocks(profile: BlkBlock): BlkBlock[] {
|
||||
return profile.blocks.filter((block) => block.name === MODIFICATIONS);
|
||||
}
|
||||
|
||||
/** Append a new modification entry to a chunk with spare capacity, opening a sibling chunk when full. */
|
||||
export function appendModificationEntry(profile: BlkBlock, entry: BlkBlock): void {
|
||||
const chunks = allModificationBlocks(profile);
|
||||
for (let index = chunks.length - 1; index >= 0; index--) {
|
||||
const chunk = chunks[index]!;
|
||||
if (chunk.blocks.length < MAX_MODIFICATION_BLOCK_ENTRIES) {
|
||||
chunk.blocks.push(entry);
|
||||
return;
|
||||
}
|
||||
}
|
||||
const nextChunk: BlkBlock = { name: MODIFICATIONS, params: [], blocks: [entry] };
|
||||
const lastChunk = chunks[chunks.length - 1];
|
||||
if (lastChunk) {
|
||||
const insertAt = profile.blocks.lastIndexOf(lastChunk) + 1;
|
||||
profile.blocks.splice(insertAt, 0, nextChunk);
|
||||
} else {
|
||||
profile.blocks.push(nextChunk);
|
||||
}
|
||||
}
|
||||
|
||||
/** Ensure every top-level `modifications` chunk stays within the 65,535-child DataBlock limit. */
|
||||
export function normalizeModificationBlocks(profile: BlkBlock): void {
|
||||
const chunks = allModificationBlocks(profile);
|
||||
if (chunks.length === 0) return;
|
||||
const needsRebalance = chunks.some((chunk) => chunk.blocks.length > MAX_MODIFICATION_BLOCK_ENTRIES)
|
||||
|| (chunks.length > 1 && chunks.some((chunk) => chunk.blocks.length === 0));
|
||||
if (!needsRebalance) return;
|
||||
|
||||
const firstIndex = profile.blocks.findIndex((block) => block.name === MODIFICATIONS);
|
||||
const entries = chunks.flatMap((chunk) => chunk.blocks);
|
||||
profile.blocks = profile.blocks.filter((block) => block.name !== MODIFICATIONS);
|
||||
if (entries.length === 0) return;
|
||||
|
||||
const rebuilt: BlkBlock[] = [];
|
||||
for (let offset = 0; offset < entries.length; offset += MAX_MODIFICATION_BLOCK_ENTRIES) {
|
||||
rebuilt.push({
|
||||
name: MODIFICATIONS,
|
||||
params: [],
|
||||
blocks: entries.slice(offset, offset + MAX_MODIFICATION_BLOCK_ENTRIES),
|
||||
});
|
||||
}
|
||||
profile.blocks.splice(Math.max(0, firstIndex), 0, ...rebuilt);
|
||||
}
|
||||
|
||||
function findModificationEntry(profile: BlkBlock, key: string): BlkBlock | undefined {
|
||||
for (const chunk of profile.blocks) {
|
||||
if (chunk.name !== MODIFICATIONS) continue;
|
||||
const found = chunk.blocks.find((entry) => entry.name === key);
|
||||
if (found) return found;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function modificationRecord(profile: BlkBlock, vehicle: string, modification: string): ModificationRecord | undefined {
|
||||
const block = findBlock(profile, MODIFICATIONS);
|
||||
const record = block && findBlock(block, recordName(vehicle, modification));
|
||||
const record = findModificationEntry(profile, recordName(vehicle, modification));
|
||||
if (!record) return undefined;
|
||||
return {
|
||||
silverLionsSpent: intOf(record, 'wpSpent'),
|
||||
@@ -42,12 +107,17 @@ export function modificationRecord(profile: BlkBlock, vehicle: string, modificat
|
||||
}
|
||||
|
||||
export function ownsModification(profile: BlkBlock, vehicle: string, modification: string): boolean {
|
||||
return modificationRecord(profile, vehicle, modification) !== undefined;
|
||||
return findModificationEntry(profile, recordName(vehicle, modification)) !== undefined;
|
||||
}
|
||||
|
||||
export function writeModificationRecord(profile: BlkBlock, vehicle: string, modification: string, record: ModificationRecord): void {
|
||||
const block = ensureBlock(ensureBlock(profile, MODIFICATIONS), recordName(vehicle, modification));
|
||||
block.params = orderedParams(record);
|
||||
const key = recordName(vehicle, modification);
|
||||
const existing = findModificationEntry(profile, key);
|
||||
if (existing) {
|
||||
existing.params = orderedParams(record);
|
||||
return;
|
||||
}
|
||||
appendModificationEntry(profile, { name: key, params: orderedParams(record), blocks: [] });
|
||||
}
|
||||
|
||||
function orderedParams(record: ModificationRecord): BlkParam[] {
|
||||
|
||||
@@ -3,9 +3,9 @@ import { ClanStore } from '../clans/clan-store.ts';
|
||||
import { DatasetCache } from '../game-data/datasets/dataset-cache.ts';
|
||||
import { vehicleCatalogue } from '../game-data/datasets/vehicle-catalogue.ts';
|
||||
import { GameFiles } from '../game-data/game-files.ts';
|
||||
import { ProfileEquipmentIndex } from '../modifications/profile-equipment-index.ts';
|
||||
import { addOwnedVehicle, ownedVehicles } from '../profile/profile-hangar.ts';
|
||||
import { ownsModification, writeModificationRecord } from '../profile/profile-modifications.ts';
|
||||
import { researchPointsOf, setResearchPoints } from '../profile/profile-vehicle-research.ts';
|
||||
import { researchPointsOf } from '../profile/profile-vehicle-research.ts';
|
||||
import { setUpProfiles } from '../profiles-setup.ts';
|
||||
import { TechTree } from '../research/tech-tree.ts';
|
||||
import { loadTuning } from '../tuning/tuning.ts';
|
||||
@@ -15,7 +15,7 @@ export interface ResearchBranch {
|
||||
readonly country: string;
|
||||
readonly type: string;
|
||||
}
|
||||
export type ResearchOperation = 'research' | 'purchase' | 'equipment';
|
||||
export type ResearchOperation = 'purchase' | 'equipment';
|
||||
|
||||
function tree(location: SaveLocation) {
|
||||
const gameFiles = new GameFiles(location.gameFolder);
|
||||
@@ -52,21 +52,19 @@ export function editSaveResearch(location: SaveLocation, userId: string, branch:
|
||||
const { profiles, equipment } = setUpProfiles(location.dataFolder, gameFiles, datasets, tuning, { accounts, clans }, vehicles);
|
||||
profiles.update(userId, (profile) => {
|
||||
const owned = ownedVehicles(profile);
|
||||
const index = operation === 'equipment' ? new ProfileEquipmentIndex(profile) : undefined;
|
||||
for (const unit of units) {
|
||||
if (operation === 'research' && unit.kind === 'research' && !owned.has(unit.name)) {
|
||||
setResearchPoints(profile, unit.name, Math.max(researchPointsOf(profile, unit.name), unit.researchPoints));
|
||||
}
|
||||
if (operation === 'purchase' && (unit.kind === 'research' || unit.kind === 'purchase')) {
|
||||
addOwnedVehicle(profile, unit.name);
|
||||
for (const part of unit.parts) addOwnedVehicle(profile, part);
|
||||
}
|
||||
if (operation === 'equipment' && owned.has(unit.name)) {
|
||||
if (index && owned.has(unit.name)) {
|
||||
const enabledGroups = new Set<string>();
|
||||
for (const mod of equipment.vehicle(unit.name)?.modifications ?? []) {
|
||||
if (mod.name === 'premExpMul' || mod.goldenEagles > 0 || ownsModification(profile, unit.name, mod.name)) continue;
|
||||
if (mod.name === 'premExpMul' || mod.goldenEagles > 0 || index.ownsModification(unit.name, mod.name)) continue;
|
||||
const enable = mod.defaultEnabled && (!mod.exclusiveGroup || !enabledGroups.has(mod.exclusiveGroup));
|
||||
if (enable && mod.exclusiveGroup) enabledGroups.add(mod.exclusiveGroup);
|
||||
writeModificationRecord(profile, unit.name, mod.name, {
|
||||
index.writeModificationRecord(unit.name, mod.name, {
|
||||
silverLionsSpent: 0, goldenEaglesSpent: 0, enabled: enable, count: Math.max(1, mod.maxCount),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
import { existsSync, readFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { decodeBlk, encodeBlk, type BlkBlock } from '@wto/blk';
|
||||
import { normalizeModificationBlocks } from '../profile/profile-modifications.ts';
|
||||
import { writeFileAtomic } from '../storage/atomic-file.ts';
|
||||
import type { SaveUpgrades } from './save-upgrades.ts';
|
||||
|
||||
@@ -44,6 +45,7 @@ export class SaveStore {
|
||||
saveProfile(userId: string, profile: BlkBlock): void {
|
||||
const now = new Date().toISOString();
|
||||
const previous = existsSync(this.#infoPath(userId)) ? (JSON.parse(readFileSync(this.#infoPath(userId), 'utf8')) as SaveInfo) : undefined;
|
||||
normalizeModificationBlocks(profile);
|
||||
writeFileAtomic(this.#profilePath(userId), encodeBlk(profile));
|
||||
const info: SaveInfo = { formatVersion: this.#upgrades.currentFormat, created: previous?.created ?? now, updated: now };
|
||||
writeFileAtomic(this.#infoPath(userId), JSON.stringify(info, null, 2));
|
||||
|
||||
@@ -10,7 +10,7 @@ import { InventoryCatalogue } from '../inventory/itemdef-catalogue.ts';
|
||||
import { intField, stringField } from '../profile/blk-fields.ts';
|
||||
import { allCrews } from '../profile/profile-crews.ts';
|
||||
import { ACTIVE_LISTS } from '../profile/profile-items.ts';
|
||||
import { recordName } from '../profile/profile-modifications.ts';
|
||||
import { normalizeModificationBlocks, recordName } from '../profile/profile-modifications.ts';
|
||||
import { loadTuning } from '../tuning/tuning.ts';
|
||||
import type { SaveLocation } from './save-editor.ts';
|
||||
|
||||
@@ -38,9 +38,13 @@ export function prepareTransferredProfile(location: SaveLocation, bytes: Uint8Ar
|
||||
['modifications', modifications], ['modsResearch', modifications], ['weapons', weapons],
|
||||
] as const;
|
||||
for (const [key, allowed] of blockKeys) {
|
||||
const collection = findBlock(profile, key);
|
||||
if (collection) collection.blocks = collection.blocks.filter((entry) => allowed.has(entry.name));
|
||||
for (const collection of profile.blocks) {
|
||||
if (collection.name === key) {
|
||||
collection.blocks = collection.blocks.filter((entry) => allowed.has(entry.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
normalizeModificationBlocks(profile);
|
||||
for (const crew of allCrews(profile)) {
|
||||
const aircraft = findBlock(crew, 'aircrafts');
|
||||
if (aircraft) {
|
||||
|
||||
@@ -25,6 +25,7 @@ function values(files: TuningFiles) {
|
||||
tankBotRespawns: battle.tankBotRespawns,
|
||||
airBotRespawns: battle.airBotRespawns,
|
||||
strikeUcavSpawnScore: battle.strikeUcavSpawnScore,
|
||||
nuclearEscalationStrategicBombers: battle.nuclearEscalationStrategicBombers,
|
||||
silverLions: newProfile.silverLions,
|
||||
goldenEagles: newProfile.goldenEagles,
|
||||
preferLineSuccessor: research.preferLineSuccessor,
|
||||
@@ -46,6 +47,7 @@ const fileOf = {
|
||||
tankBotRespawns: 'battle',
|
||||
airBotRespawns: 'battle',
|
||||
strikeUcavSpawnScore: 'battle',
|
||||
nuclearEscalationStrategicBombers: 'battle',
|
||||
silverLions: 'new-profile',
|
||||
goldenEagles: 'new-profile',
|
||||
preferLineSuccessor: 'research',
|
||||
|
||||
@@ -47,5 +47,10 @@
|
||||
|
||||
// AI bot respawn limits per battle in multi-slot versus modes.
|
||||
"tankBotRespawns": 3,
|
||||
"airBotRespawns": 2
|
||||
"airBotRespawns": 2,
|
||||
|
||||
// Offer a stage-3 megaton strategic bomber (B-52H / Tu-95M) alongside the tactical nuclear
|
||||
// carrier in Air RB Nuclear Escalation (sub-mode 103). Disable to use tactical 5 kt / 30 kt
|
||||
// carriers only, matching the regular live rotation.
|
||||
"nuclearEscalationStrategicBombers": true
|
||||
}
|
||||
@@ -23,7 +23,7 @@ New-Item -ItemType Directory -Force $obj | Out-Null
|
||||
$sources = @(
|
||||
"$src\dll_main.c", "$src\hook_config.c", "$src\redirect_rules.c", "$src\resolver_hooks.c", "$src\connection_hooks.c",
|
||||
"$src\local_mp_core.c", "$src\local_mp_values.c", "$src\local_mp_players.c", "$src\local_mp_loadout.c", "$src\local_mp_actions.c", "$src\local_mp_awards.c", "$src\local_mp_kills.c", "$src\local_mp_events.c", "$src\local_mp_scores.c", "$src\local_mp_nuke.c", "$src\local_mp_support.c",
|
||||
"$src\local_mp_damage_notifications.c",
|
||||
"$src\local_mp_damage_notifications.c", "$src\local_mp_air_events.c",
|
||||
"$mh\src\hook.c", "$mh\src\buffer.c", "$mh\src\trampoline.c", "$mh\src\hde\hde64.c"
|
||||
) | ForEach-Object { '"' + (Resolve-Path $_) + '"' }
|
||||
|
||||
|
||||
@@ -0,0 +1,323 @@
|
||||
/*
|
||||
* Ground Arcade air events (fighter/attacker/bomber killstreaks) on a LocalMP host.
|
||||
*
|
||||
* Four gaps keep stock Ground Arcade air events from running in LocalMP:
|
||||
* 1. prepare_local_mission clears MissionSettings.useKillStreaks during LocalMP setup.
|
||||
* 2. Local AI kills go through local_mp_kills.c and do not advance native killstreak counters.
|
||||
* 3. BombingKillStreakEvent::switchPlayerUnit spawns the aircraft only by broadcasting
|
||||
* UnitRespawn (0xf030) through mpi::sendto, which has no local receiver on a LocalMP host.
|
||||
* 4. If a LocalMP air-event respawn ever supplies a ground-level pose, we rebuild an airborne
|
||||
* approach using the stock gameplay.blk spawnPos parameters for the match rank.
|
||||
*/
|
||||
#include "hooks.h"
|
||||
#include "hook_config.h"
|
||||
#include "local_mp_internal.h"
|
||||
#include "local_mp_offsets.h"
|
||||
#include "local_mp_values.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <math.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef struct LocalMpAirSpawn {
|
||||
double position[3];
|
||||
float orientation[4];
|
||||
float velocity[3];
|
||||
uint8_t options[0x14];
|
||||
} LocalMpAirSpawn;
|
||||
|
||||
C_ASSERT(offsetof(LocalMpAirSpawn, orientation) == 0x18);
|
||||
C_ASSERT(offsetof(LocalMpAirSpawn, velocity) == 0x28);
|
||||
C_ASSERT(sizeof(LocalMpAirSpawn) == 0x48);
|
||||
|
||||
typedef void (__fastcall *PrepareLocalMissionFn)(void *mission);
|
||||
typedef void (__fastcall *AddKillStreakPointsFn)(uint8_t *player, uint32_t rule, int32_t points, int32_t related_rule);
|
||||
typedef void (__fastcall *SwitchPlayerUnitFn)(void *event_mgr, void *participant, uint8_t to_air);
|
||||
typedef void (__fastcall *SendUnitRespawnFn)(uint8_t *unit, const LocalMpAirSpawn *spawn);
|
||||
typedef void (__fastcall *MpiSendToFn)(void *message, uint8_t recipient);
|
||||
typedef uint64_t (__fastcall *UnitOnEventFn)(void *unit, const void *event, void *arg3, void *arg4);
|
||||
typedef void (__fastcall *GetBattleCenterFn)(float center[2]);
|
||||
typedef uint8_t (__fastcall *GetTerrainHeightFn)(const void *terrain, float x, float z, float *height,
|
||||
void *normal, void *material);
|
||||
typedef void (__fastcall *GetOrientationFn)(float quaternion[4], const float transform[12]);
|
||||
|
||||
static PrepareLocalMissionFn orig_prepare_local_mission;
|
||||
static SwitchPlayerUnitFn orig_switch_player_unit;
|
||||
static SendUnitRespawnFn orig_send_unit_respawn;
|
||||
static MpiSendToFn orig_mpi_sendto;
|
||||
|
||||
static __declspec(thread) int g_in_air_event_switch;
|
||||
static __declspec(thread) uint8_t *g_respawn_unit;
|
||||
static int g_air_events_active;
|
||||
static int g_credit_log_count;
|
||||
|
||||
enum { AIR_EVENT_CREDIT_LOG_LIMIT = 12 };
|
||||
|
||||
static int ground_arcade_air_events_enabled(void)
|
||||
{
|
||||
const uint8_t *settings = g_local_mp_mission_settings;
|
||||
const char *mode;
|
||||
|
||||
if (!g_air_events_active || settings == NULL || !local_mp_is_host())
|
||||
return 0;
|
||||
if (*g_lmp.use_kill_streaks != 1)
|
||||
return 0;
|
||||
mode = *(const char *const *)(settings + LMP_MIS_OFF_MODE_NAME);
|
||||
return mode != NULL && strcmp(mode, "tank_event_in_random_battles_arcade") == 0;
|
||||
}
|
||||
|
||||
/* Resolve a killstreak tag id through Dagor's FastNameMap string table layout. */
|
||||
static const char *kill_streak_rule_tag(uint32_t id)
|
||||
{
|
||||
const uint8_t *nm = g_lmp.kill_streak_name_map;
|
||||
const uint64_t *entries;
|
||||
uint32_t count, packed, page, page_count;
|
||||
unsigned shift;
|
||||
const uint8_t *pages, *page_slot;
|
||||
const char *strings;
|
||||
|
||||
if (nm == NULL)
|
||||
return NULL;
|
||||
entries = *(const uint64_t *const *)(nm + LMP_NAMEMAP_OFF_ENTRIES);
|
||||
count = *(const uint32_t *)(nm + LMP_NAMEMAP_OFF_COUNT);
|
||||
shift = nm[LMP_NAMEMAP_OFF_SHIFT];
|
||||
if (entries == NULL || id >= count || shift >= 32u)
|
||||
return NULL;
|
||||
packed = (uint32_t)entries[id];
|
||||
page = packed >> shift;
|
||||
page_count = *(const uint32_t *)(nm + LMP_NAMEMAP_OFF_PAGE_COUNT);
|
||||
pages = *(const uint8_t *const *)(nm + LMP_NAMEMAP_OFF_PAGES);
|
||||
if (page == page_count)
|
||||
page_slot = nm + LMP_NAMEMAP_OFF_TAIL_PAGE;
|
||||
else if (page < page_count && pages != NULL)
|
||||
page_slot = pages + (size_t)page * 16u;
|
||||
else
|
||||
return NULL;
|
||||
strings = *(const char *const *)page_slot;
|
||||
return strings != NULL ? strings + (packed & ((1u << shift) - 1u)) : NULL;
|
||||
}
|
||||
|
||||
static int is_air_event_tag(const char *tag)
|
||||
{
|
||||
return tag != NULL && (strcmp(tag, "fighter") == 0 || strcmp(tag, "attacker") == 0 || strcmp(tag, "bomber") == 0);
|
||||
}
|
||||
|
||||
static float surface_height(const void *terrain, float x, float z)
|
||||
{
|
||||
float height = 0.0f;
|
||||
GetTerrainHeightFn query = (GetTerrainHeightFn)g_lmp.air_event_terrain_height;
|
||||
|
||||
if (query != NULL && query(terrain, x, z, &height, NULL, NULL) && isfinite(height) && height > 0.0f)
|
||||
return height;
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
/* Read stock spawn distance, altitude and speed from gameplay.blk's spawnPos table for this rank. */
|
||||
static int lookup_stock_spawn_params(float *out_dist, float *out_alt, float *out_speed_mps)
|
||||
{
|
||||
const uint8_t *gameplay = g_lmp.gameplay ? *(const uint8_t *const *)g_lmp.gameplay : NULL;
|
||||
const uint8_t *rules;
|
||||
uint32_t rule_count, i;
|
||||
int32_t rank;
|
||||
|
||||
if (gameplay == NULL || g_lmp.mission_max_rank == NULL || LMP_KS_SPAWN_POS_STRIDE < 0x50u)
|
||||
return 0;
|
||||
rules = *(const uint8_t *const *)(gameplay + LMP_GP_OFF_KS_RULES);
|
||||
rule_count = *(const uint32_t *)(gameplay + LMP_GP_OFF_KS_RULE_COUNT);
|
||||
rank = *(const int32_t *)g_lmp.mission_max_rank;
|
||||
if (rules == NULL || rule_count > 256u)
|
||||
return 0;
|
||||
for (i = 0; i < rule_count; i++) {
|
||||
const uint8_t *rule = rules + (size_t)i * LMP_KS_RULE_STRIDE;
|
||||
const char *tag = kill_streak_rule_tag(*(const uint32_t *)(rule + LMP_KS_RULE_OFF_TAG));
|
||||
const uint8_t *table;
|
||||
uint32_t count, j;
|
||||
|
||||
if (tag == NULL || (strcmp(tag, "attacker") != 0 && strcmp(tag, "bomber") != 0))
|
||||
continue;
|
||||
table = *(const uint8_t *const *)(rule + LMP_KS_RULE_OFF_SPAWN_POS);
|
||||
count = *(const uint32_t *)(rule + LMP_KS_RULE_OFF_SPAWN_POS_CNT);
|
||||
if (table == NULL || count > 64u)
|
||||
continue;
|
||||
for (j = 0; j < count; j++) {
|
||||
const uint8_t *row = table + (size_t)j * LMP_KS_SPAWN_POS_STRIDE;
|
||||
int32_t min_r = *(const int32_t *)(row + LMP_KS_SP_OFF_MIN_RANK);
|
||||
int32_t max_r = *(const int32_t *)(row + LMP_KS_SP_OFF_MAX_RANK);
|
||||
if (rank >= min_r && rank <= max_r) {
|
||||
float dist = *(const float *)(row + LMP_KS_SP_OFF_INIT_DIST);
|
||||
float alt = *(const float *)(row + LMP_KS_SP_OFF_INIT_ALT);
|
||||
float kmh = *(const float *)(row + LMP_KS_SP_OFF_INIT_SPEED_KMH);
|
||||
if (isfinite(dist) && dist > 100.0f && isfinite(alt) && alt > 100.0f && isfinite(kmh) && kmh > 50.0f) {
|
||||
*out_dist = dist;
|
||||
*out_alt = alt;
|
||||
*out_speed_mps = kmh / 3.6f;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Rebuild an airborne pose from stock gameplay.blk spawnPos only when LocalMP supplied a surface pose. */
|
||||
static int repair_air_spawn_if_invalid(LocalMpAirSpawn *spawn)
|
||||
{
|
||||
const uint8_t *app = g_local_mp_app ? *g_local_mp_app : NULL;
|
||||
const void *terrain = app ? *(const void *const *)(app + LMP_APP_OFF_TERRAIN) : NULL;
|
||||
float x = (float)spawn->position[0], y = (float)spawn->position[1], z = (float)spawn->position[2];
|
||||
float dx = spawn->velocity[0], dz = spawn->velocity[2];
|
||||
float speed = sqrtf(dx * dx + dz * dz);
|
||||
int valid_speed = isfinite(speed) && speed >= 25.0f;
|
||||
float center[2], approach, alt, stock_speed, highest = 0.0f;
|
||||
float transform[12];
|
||||
unsigned i;
|
||||
|
||||
if (terrain == NULL || *(const void *const *)(app + LMP_APP_OFF_SCORE_RULES) == NULL)
|
||||
return 0;
|
||||
if (valid_speed && fabsf(x) < 1e7f && fabsf(z) < 1e7f && isfinite(y) &&
|
||||
y >= surface_height(terrain, x, z) + 100.0f)
|
||||
return 0;
|
||||
if (!lookup_stock_spawn_params(&approach, &alt, &stock_speed))
|
||||
return 0;
|
||||
((GetBattleCenterFn)g_lmp.air_event_battle_center)(center);
|
||||
if (!isfinite(center[0]) || !isfinite(center[1]))
|
||||
return 0;
|
||||
|
||||
dx = valid_speed ? dx / speed : 1.0f;
|
||||
dz = valid_speed ? dz / speed : 0.0f;
|
||||
for (i = 0; i <= 14u; i++) {
|
||||
float d = approach * (float)i / 14.0f;
|
||||
float h = surface_height(terrain, center[0] - dx * d, center[1] - dz * d);
|
||||
if (h > highest)
|
||||
highest = h;
|
||||
}
|
||||
x = center[0] - dx * approach;
|
||||
y = highest + alt;
|
||||
z = center[1] - dz * approach;
|
||||
speed = valid_speed ? speed : stock_speed;
|
||||
memset(transform, 0, sizeof(transform));
|
||||
transform[0] = dx; transform[2] = dz; transform[4] = 1.0f;
|
||||
transform[6] = -dz; transform[8] = dx;
|
||||
transform[9] = x; transform[10] = y; transform[11] = z;
|
||||
((GetOrientationFn)g_lmp.air_event_orientation)(spawn->orientation, transform);
|
||||
spawn->position[0] = x;
|
||||
spawn->position[1] = y;
|
||||
spawn->position[2] = z;
|
||||
spawn->velocity[0] = dx * speed;
|
||||
spawn->velocity[1] = 0.0f;
|
||||
spawn->velocity[2] = dz * speed;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void __fastcall hook_prepare_local_mission(void *mission)
|
||||
{
|
||||
int restore = ground_arcade_air_events_enabled();
|
||||
|
||||
orig_prepare_local_mission(mission);
|
||||
if (restore && local_mp_is_host()) {
|
||||
*g_lmp.use_kill_streaks = 1;
|
||||
log_line("local_mp: preserved MissionSettings.useKillStreaks for Ground Arcade");
|
||||
}
|
||||
}
|
||||
|
||||
static void __fastcall hook_switch_player_unit(void *event_mgr, void *participant, uint8_t to_air)
|
||||
{
|
||||
int previous = g_in_air_event_switch;
|
||||
|
||||
if (to_air != 0 && ground_arcade_air_events_enabled())
|
||||
g_in_air_event_switch = 1;
|
||||
orig_switch_player_unit(event_mgr, participant, to_air);
|
||||
g_in_air_event_switch = previous;
|
||||
}
|
||||
|
||||
static void __fastcall hook_send_unit_respawn(uint8_t *unit, const LocalMpAirSpawn *spawn)
|
||||
{
|
||||
uint8_t *previous;
|
||||
__declspec(align(16)) LocalMpAirSpawn recovered;
|
||||
|
||||
if (!g_in_air_event_switch || unit == NULL || spawn == NULL || !ground_arcade_air_events_enabled()) {
|
||||
orig_send_unit_respawn(unit, spawn);
|
||||
return;
|
||||
}
|
||||
previous = g_respawn_unit;
|
||||
g_respawn_unit = unit;
|
||||
recovered = *spawn;
|
||||
if (repair_air_spawn_if_invalid(&recovered)) {
|
||||
log_line("local_mp: rebuilt Ground Arcade air spawn from (%.1f, %.1f, %.1f) to (%.1f, %.1f, %.1f)",
|
||||
spawn->position[0], spawn->position[1], spawn->position[2],
|
||||
recovered.position[0], recovered.position[1], recovered.position[2]);
|
||||
spawn = &recovered;
|
||||
}
|
||||
orig_send_unit_respawn(unit, spawn);
|
||||
g_respawn_unit = previous;
|
||||
}
|
||||
|
||||
static void __fastcall hook_mpi_sendto(void *message, uint8_t recipient)
|
||||
{
|
||||
uint8_t *unit = g_respawn_unit;
|
||||
const uint8_t *packet = (const uint8_t *)message;
|
||||
|
||||
if (unit == NULL || recipient != 0xffu || packet == NULL ||
|
||||
*(uint8_t *const *)(packet + LMP_MPI_MSG_OFF_OBJ) != unit ||
|
||||
*(const uint16_t *)(packet + LMP_MPI_MSG_OFF_ID) != LMP_MPI_MSG_UNIT_RESPAWN) {
|
||||
orig_mpi_sendto(message, recipient);
|
||||
return;
|
||||
}
|
||||
/* Clear scope while delivering so nested messages follow the normal mpi::sendto path. */
|
||||
g_respawn_unit = NULL;
|
||||
((UnitOnEventFn)g_lmp.unit_on_event)(unit, message, NULL, NULL);
|
||||
g_respawn_unit = unit;
|
||||
}
|
||||
|
||||
void local_mp_credit_air_event_kill(uint8_t *player, int aircraft_victim)
|
||||
{
|
||||
const uint8_t *gameplay, *rules, *progress;
|
||||
uint32_t rule_count, player_rule_count, i;
|
||||
AddKillStreakPointsFn add_points = (AddKillStreakPointsFn)g_lmp.add_kill_streak_points;
|
||||
|
||||
if (add_points == NULL || player == NULL || !ground_arcade_air_events_enabled())
|
||||
return;
|
||||
gameplay = *(const uint8_t *const *)g_lmp.gameplay;
|
||||
progress = *(const uint8_t *const *)(player + LMP_MP_OFF_KS_PROGRESS + LMP_TAB_OFF_DATA);
|
||||
player_rule_count = *(const uint32_t *)(player + LMP_MP_OFF_KS_PROGRESS + LMP_TAB_OFF_COUNT);
|
||||
if (gameplay == NULL || progress == NULL || player_rule_count == 0u)
|
||||
return;
|
||||
rules = *(const uint8_t *const *)(gameplay + LMP_GP_OFF_KS_RULES);
|
||||
rule_count = *(const uint32_t *)(gameplay + LMP_GP_OFF_KS_RULE_COUNT);
|
||||
if (rules == NULL || rule_count > 256u || player_rule_count > rule_count)
|
||||
return;
|
||||
|
||||
for (i = 0; i < player_rule_count; i++) {
|
||||
const uint8_t *rule = rules + (size_t)i * LMP_KS_RULE_STRIDE;
|
||||
const char *tag = kill_streak_rule_tag(*(const uint32_t *)(rule + LMP_KS_RULE_OFF_TAG));
|
||||
int32_t points;
|
||||
|
||||
if (!is_air_event_tag(tag))
|
||||
continue;
|
||||
points = *(const int32_t *)(rule + (aircraft_victim ? LMP_KS_RULE_OFF_AIR_AI_MULT : LMP_KS_RULE_OFF_GROUND_AI_MULT));
|
||||
if (points > 0) {
|
||||
add_points(player, i, points, -1);
|
||||
if (g_credit_log_count < AIR_EVENT_CREDIT_LOG_LIMIT) {
|
||||
++g_credit_log_count;
|
||||
log_line("local_mp: Ground Arcade air event %s +%d (counter %u)", tag, (int)points,
|
||||
(unsigned)progress[(size_t)i * LMP_KS_PROGRESS_STRIDE]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int install_local_mp_air_event_hooks(void)
|
||||
{
|
||||
const LocalMpHookSpec hooks[] = {
|
||||
{ "prepare_local_mission", g_lmp.prepare_local_mission, (void *)&hook_prepare_local_mission, (void **)&orig_prepare_local_mission },
|
||||
{ "air_event_switch_unit", g_lmp.air_event_switch_unit, (void *)&hook_switch_player_unit, (void **)&orig_switch_player_unit },
|
||||
{ "send_unit_respawn", g_lmp.send_unit_respawn, (void *)&hook_send_unit_respawn, (void **)&orig_send_unit_respawn },
|
||||
{ "mpi_sendto", g_lmp.mpi_sendto, (void *)&hook_mpi_sendto, (void **)&orig_mpi_sendto },
|
||||
};
|
||||
|
||||
if (!local_mp_queue_hooks("local_mp_air_events", hooks, sizeof(hooks) / sizeof(hooks[0])))
|
||||
return 0;
|
||||
g_air_events_active = 1;
|
||||
return 1;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Reports the local player's combat events to the GUI scripts.
|
||||
* Reports the local player's combat events and confirmed airfield departures to the GUI scripts.
|
||||
*
|
||||
* Online, the battle server prices every combat event and sends it to the client
|
||||
* (packet 0xb03d -> GameSaveData::addScoreMessage), which raises the HUD script event
|
||||
@@ -95,6 +95,21 @@ void local_mp_report_nuclear_strike(void)
|
||||
fn_blk_dtor(blk);
|
||||
}
|
||||
|
||||
void local_mp_report_airfield_spawn(const char *unit_name, int32_t base_id)
|
||||
{
|
||||
__declspec(align(16)) uint8_t blk[LMP_BLK_SIZE];
|
||||
uint8_t *gsd = g_game_save_data ? *g_game_save_data : NULL;
|
||||
|
||||
if (gsd == NULL || fn_hud_notify_script == NULL || unit_name == NULL || base_id < 0)
|
||||
return;
|
||||
memset(blk, 0, sizeof(blk));
|
||||
fn_blk_ctor(blk);
|
||||
fn_blk_set_str(blk, "unitName", unit_name);
|
||||
blk_set_int(blk, "baseId", base_id);
|
||||
fn_hud_notify_script(gsd + LMP_GSD_OFF_HUD_QUEUE, "wtoLocalMpAirfieldSpawn", blk);
|
||||
fn_blk_dtor(blk);
|
||||
}
|
||||
|
||||
int install_local_mp_award_hooks(void)
|
||||
{
|
||||
g_game_save_data = (uint8_t **)g_lmp.game_save_data;
|
||||
|
||||
@@ -132,16 +132,17 @@ typedef struct LocalMpModule {
|
||||
} LocalMpModule;
|
||||
|
||||
static const LocalMpModule MODULES[] = {
|
||||
{ "local_mp_awards", install_local_mp_award_hooks },
|
||||
{ "local_mp_players", install_local_mp_player_hooks },
|
||||
{ "local_mp_loadout", install_local_mp_loadout_hooks },
|
||||
{ "local_mp_actions", install_local_mp_action_hooks },
|
||||
{ "local_mp_awards", install_local_mp_award_hooks },
|
||||
{ "local_mp_scores", install_local_mp_score_reader },
|
||||
{ "local_mp_kills", install_local_mp_kill_hooks },
|
||||
{ "local_mp_events", install_local_mp_event_hooks },
|
||||
{ "local_mp_nuke", install_local_mp_nuke_hooks },
|
||||
{ "local_mp_support", install_local_mp_support_hooks },
|
||||
{ "local_mp_damage_notifications", install_local_mp_damage_notification_hooks },
|
||||
{ "local_mp_air_events", install_local_mp_air_event_hooks },
|
||||
};
|
||||
|
||||
static void use_core_values(void)
|
||||
|
||||
@@ -58,15 +58,17 @@ char *local_mp_strdup(const char *s);
|
||||
const char *local_mp_unit_name(const uint8_t *unit);
|
||||
|
||||
/* Player state & slot tracking notifications shared with loadout module. */
|
||||
void local_mp_players_queue_spawn(int32_t slot_id, int32_t spare_type, int is_silent);
|
||||
void local_mp_players_queue_spawn(int32_t slot_id, int32_t spare_type, int32_t base_id, int is_silent);
|
||||
|
||||
/* Combat event reporting to the GUI scripts (local_mp_awards.c). */
|
||||
/* Local player events sent to the GUI scripts (local_mp_awards.c). */
|
||||
void local_mp_report_award_event(const LocalMpAwardEvent *ev);
|
||||
void local_mp_report_nuclear_strike(void);
|
||||
void local_mp_report_airfield_spawn(const char *unit_name, int32_t base_id);
|
||||
|
||||
/* A destroyed unit that is some player's mission support unit: its reference is freed once the
|
||||
* player has been given back control (local_mp_support.c). */
|
||||
void local_mp_support_unit_dead(const uint8_t *victim);
|
||||
void local_mp_credit_air_event_kill(uint8_t *player, int aircraft_victim);
|
||||
const char *local_mp_unit_exp_class(const uint8_t *unit);
|
||||
|
||||
/* Mission scores of combat events from the mission settings (local_mp_scores.c). */
|
||||
@@ -103,3 +105,4 @@ int install_local_mp_score_reader(void);
|
||||
int install_local_mp_nuke_hooks(void);
|
||||
int install_local_mp_support_hooks(void);
|
||||
int install_local_mp_damage_notification_hooks(void);
|
||||
int install_local_mp_air_event_hooks(void);
|
||||
@@ -95,6 +95,8 @@ static void record_enemy_kill(uint8_t *killer_mp, uint8_t *victim, int is_pvp)
|
||||
|
||||
if (local_mp_is_local_mplayer(killer_mp)) {
|
||||
LocalMpAwardEvent award = { ev, victim, is_pvp, 0, own_sev ? "from_severe_damage" : NULL, 0 };
|
||||
if (!is_ship && !is_human)
|
||||
local_mp_credit_air_event_kill(killer_mp, is_air);
|
||||
local_mp_report_award_event(&award);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/*
|
||||
* LocalMP vehicle loadout, modification map, decals, 3D attachables, and crew-skill bridge.
|
||||
* LocalMP vehicle loadout, modification map, decals, and 3D attachables.
|
||||
*
|
||||
* The 2.61.0.37 client has no receiver for its own vehicle change request (0xb01d,
|
||||
* SemChangeAircraftRequest) on a host; hook_sem_change_aircraft_send builds the
|
||||
* ChangeUnitReflection from the request (weapon, modifications, bullets, skin, decals,
|
||||
* attachables, crew skills, spawn base) and calls Unit::changeAircraft itself.
|
||||
* attachables, spawn base) and calls Unit::changeAircraft itself.
|
||||
*/
|
||||
#include "hooks.h"
|
||||
#include "hook_config.h"
|
||||
@@ -37,7 +37,6 @@ typedef const void *(__fastcall *GetAttachablesBlkFn)(
|
||||
);
|
||||
typedef uint64_t (__fastcall *StrHashFnv1Fn)(const char *str, size_t len);
|
||||
typedef int32_t (__fastcall *NameMapAddNameIdFn)(void *map, const char *str, size_t len, uint64_t hash);
|
||||
typedef void (__fastcall *CrewSkillsInitFn)(void *crew_skills, void *econ_state, const char *unit_name, float mult);
|
||||
|
||||
static SemChangeAircraftSendFn orig_sem_send;
|
||||
static ReflCtorFn fn_refl_ctor;
|
||||
@@ -50,7 +49,6 @@ static GetDecalsBlkFn fn_get_decals_blk;
|
||||
static GetAttachablesBlkFn fn_get_attachables_blk;
|
||||
static StrHashFnv1Fn fn_str_hash;
|
||||
static NameMapAddNameIdFn fn_namemap_add;
|
||||
static CrewSkillsInitFn fn_crew_skills_init;
|
||||
|
||||
static void populate_namemap_csv(void *map, const char *csv)
|
||||
{
|
||||
@@ -133,7 +131,6 @@ static void __fastcall hook_sem_change_aircraft_send(
|
||||
{
|
||||
uint8_t *hero, *mplayer, *econ_state, *req;
|
||||
const void *bullets_begin, *bullets_end;
|
||||
void *crew_skills;
|
||||
int32_t req_slot_id, req_base_id, req_spare_type;
|
||||
int is_silent;
|
||||
__declspec(align(16)) uint8_t refl[LMP_REFL_SIZE];
|
||||
@@ -188,14 +185,11 @@ static void __fastcall hook_sem_change_aircraft_send(
|
||||
fn_unit_change_aircraft(hero, refl, 1);
|
||||
fn_refl_dtor(refl);
|
||||
|
||||
crew_skills = *(void **)(hero + LMP_UNIT_OFF_CREW_SKILLS);
|
||||
if (crew_skills != NULL && unit_name != NULL && unit_name[0] != '\0')
|
||||
fn_crew_skills_init(crew_skills, econ_state, unit_name, 1.0f);
|
||||
if (mplayer[LMP_MP_OFF_GUI_STATE] != LMP_GUI_STATE_PILOT_CONTROL &&
|
||||
mplayer[LMP_MP_OFF_GUI_STATE] != LMP_GUI_STATE_CA_READY)
|
||||
g_lmp_set_player_gui_state((int32_t)mplayer[LMP_MP_OFF_PID], LMP_GUI_STATE_CA_READY);
|
||||
|
||||
local_mp_players_queue_spawn(req_slot_id, req_spare_type, is_silent);
|
||||
local_mp_players_queue_spawn(req_slot_id, req_spare_type, req_base_id, is_silent);
|
||||
log_line("local_mp: configured unit='%s' weapon='%s' slot=%d silent=%d",
|
||||
unit_name ? unit_name : "", weapon_name ? weapon_name : "", (int)req_slot_id, is_silent);
|
||||
}
|
||||
@@ -222,7 +216,6 @@ int install_local_mp_loadout_hooks(void)
|
||||
fn_get_attachables_blk = (GetAttachablesBlkFn)g_lmp.get_attachables_blk;
|
||||
fn_str_hash = (StrHashFnv1Fn)g_lmp.str_hash_fnv1;
|
||||
fn_namemap_add = (NameMapAddNameIdFn)g_lmp.namemap_add_name_id;
|
||||
fn_crew_skills_init = (CrewSkillsInitFn)g_lmp.crew_skills_init;
|
||||
|
||||
return local_mp_queue_hooks("local_mp_loadout", hooks, sizeof(hooks) / sizeof(hooks[0]));
|
||||
}
|
||||
@@ -55,6 +55,10 @@
|
||||
#define LMP_REQ_OFF_RESP_BASE_ID 0x00b8u
|
||||
#define LMP_REQ_OFF_SPARE_TYPE 0x00c0u
|
||||
|
||||
/* First field of the matching info passed to MPlayer::initFromMatching (0x59ead4 on 2.61.0.37,
|
||||
* 0x59f7e4 on 2.61.0.58), copied into MPlayer+0xab0 and read by the 0xf10f squad target relay. */
|
||||
#define LMP_MATCH_INFO_OFF_SQUAD_ID 0x0000u
|
||||
|
||||
/* Multiplayer */
|
||||
#define LMP_MP_MGR_OFF_IS_HOST (g_lmp.mp_is_host)
|
||||
#define LMP_MP_MGR_OFF_IS_LOCAL_MP (g_lmp.mp_is_local_mp)
|
||||
@@ -64,6 +68,7 @@
|
||||
#define LMP_MP_MGR_OFF_CHAT_HOST (g_lmp.mp_chat_host)
|
||||
|
||||
/* App and the economic state */
|
||||
#define LMP_APP_OFF_TERRAIN (g_lmp.app_terrain)
|
||||
#define LMP_APP_OFF_SCORE_RULES (g_lmp.app_score_rules)
|
||||
#define LMP_APP_OFF_ECON_HOLDER (g_lmp.app_econ_holder)
|
||||
#define LMP_ECON_HOLDER_OFF_STATE (g_lmp.econ_state)
|
||||
@@ -73,6 +78,7 @@
|
||||
#define LMP_REQ_OFF_SLOT_ID (g_lmp.req_slot_id)
|
||||
|
||||
/* MissionSettings and the matching info */
|
||||
#define LMP_MIS_OFF_MODE_NAME (g_lmp.mis_mode_name)
|
||||
#define LMP_MIS_OFF_AXIS_COUNTRY (g_lmp.mis_axis_country)
|
||||
#define LMP_MIS_OFF_ALLIES_COUNTRY (g_lmp.mis_allies_country)
|
||||
#define LMP_MIS_OFF_ARCADE_COUNTRY (g_lmp.mis_arcade_country)
|
||||
@@ -125,7 +131,6 @@
|
||||
#define LMP_UNIT_OFF_INFO (g_lmp.unit_info)
|
||||
#define LMP_UNIT_INFO_OFF_NAME (g_lmp.unit_info_name)
|
||||
#define LMP_UNIT_INFO_OFF_EXP_CLASS (g_lmp.unit_info_exp_class)
|
||||
#define LMP_UNIT_OFF_CREW_SKILLS (g_lmp.unit_crew_skills)
|
||||
#define LMP_UNIT_VTF_CHOOSE_OFFENDER (g_lmp.unit_vtf_choose_offender)
|
||||
#define LMP_UNIT_OFF_SKIP_KILL (g_lmp.unit_skip_kill)
|
||||
#define LMP_IGM_OFF_OFFENDERS_PTR (g_lmp.igm_offenders)
|
||||
@@ -170,3 +175,31 @@
|
||||
|
||||
/* GameSaveData HUD script event queue */
|
||||
#define LMP_GSD_OFF_HUD_QUEUE (g_lmp.gsd_hud_queue)
|
||||
|
||||
/* Ground Arcade air events: DagorEngine library layouts (mpi::Message, FastNameMap) and captured
|
||||
* gameplay/MPlayer killstreak fields (local_mp_air_events.c). */
|
||||
#define LMP_MPI_MSG_OFF_OBJ 0x08u
|
||||
#define LMP_MPI_MSG_OFF_ID 0x20u
|
||||
#define LMP_MPI_MSG_UNIT_RESPAWN 0xf030u
|
||||
#define LMP_NAMEMAP_OFF_ENTRIES 0x00u
|
||||
#define LMP_NAMEMAP_OFF_COUNT 0x08u
|
||||
#define LMP_NAMEMAP_OFF_TAIL_PAGE 0x10u
|
||||
#define LMP_NAMEMAP_OFF_PAGES 0x20u
|
||||
#define LMP_NAMEMAP_OFF_PAGE_COUNT 0x28u
|
||||
#define LMP_NAMEMAP_OFF_SHIFT 0x32u
|
||||
#define LMP_KS_RULE_STRIDE 0x90u
|
||||
#define LMP_KS_PROGRESS_STRIDE 0x10u
|
||||
#define LMP_KS_SP_OFF_MIN_RANK 0x00u
|
||||
#define LMP_KS_SP_OFF_MAX_RANK 0x04u
|
||||
#define LMP_KS_SP_OFF_INIT_DIST 0x08u
|
||||
#define LMP_KS_SP_OFF_INIT_ALT 0x0cu
|
||||
#define LMP_KS_SP_OFF_INIT_SPEED_KMH 0x48u
|
||||
#define LMP_GP_OFF_KS_RULES (g_lmp.gp_ks_rules)
|
||||
#define LMP_GP_OFF_KS_RULE_COUNT (g_lmp.gp_ks_rule_count)
|
||||
#define LMP_KS_RULE_OFF_TAG (g_lmp.ks_rule_tag)
|
||||
#define LMP_KS_RULE_OFF_AIR_AI_MULT (g_lmp.ks_rule_air_ai_mult)
|
||||
#define LMP_KS_RULE_OFF_GROUND_AI_MULT (g_lmp.ks_rule_ground_ai_mult)
|
||||
#define LMP_KS_RULE_OFF_SPAWN_POS (g_lmp.ks_rule_spawn_pos)
|
||||
#define LMP_KS_RULE_OFF_SPAWN_POS_CNT (g_lmp.ks_rule_spawn_pos_count)
|
||||
#define LMP_KS_SPAWN_POS_STRIDE (g_lmp.ks_spawn_pos_stride)
|
||||
#define LMP_MP_OFF_KS_PROGRESS (g_lmp.mp_ks_progress)
|
||||
@@ -25,12 +25,14 @@ static int g_accept_pending = 0;
|
||||
static int g_respawn_dispatched = 0;
|
||||
static int32_t g_pending_slot_id = -1;
|
||||
static int32_t g_pending_spare_type = -1;
|
||||
static int32_t g_pending_base_id = -1;
|
||||
|
||||
void local_mp_players_queue_spawn(int32_t slot_id, int32_t spare_type, int is_silent)
|
||||
void local_mp_players_queue_spawn(int32_t slot_id, int32_t spare_type, int32_t base_id, int is_silent)
|
||||
{
|
||||
if (!is_silent || g_pending_slot_id < 0) {
|
||||
g_pending_slot_id = slot_id;
|
||||
g_pending_spare_type = spare_type;
|
||||
g_pending_base_id = base_id;
|
||||
}
|
||||
if (!is_silent)
|
||||
g_respawn_dispatched = 0;
|
||||
@@ -106,14 +108,27 @@ static void __fastcall hook_mplayer_init_from_matching(uint8_t *mplayer, uint8_t
|
||||
int32_t desired_team = resolve_configured_player_team();
|
||||
if (desired_team == 1 || desired_team == 2)
|
||||
*(int32_t *)(info + LMP_MATCH_INFO_OFF_TEAM) = desired_team;
|
||||
if (*(int32_t *)(info + LMP_MATCH_INFO_OFF_SQUAD_ID) == 0)
|
||||
*(int32_t *)(info + LMP_MATCH_INFO_OFF_SQUAD_ID) = 1;
|
||||
local_mp_events_reset();
|
||||
log_line("local_mp: initialized local player team=%d",
|
||||
(int)(*(int32_t *)(info + LMP_MATCH_INFO_OFF_TEAM)));
|
||||
log_line("local_mp: initialized local player team=%d squad=%d",
|
||||
(int)(*(int32_t *)(info + LMP_MATCH_INFO_OFF_TEAM)),
|
||||
(int)(*(int32_t *)(info + LMP_MATCH_INFO_OFF_SQUAD_ID)));
|
||||
}
|
||||
orig_mplayer_init_matching(mplayer, info, uid);
|
||||
}
|
||||
|
||||
static void consume_pending_slot_if_spawned(uint8_t *mplayer)
|
||||
static int has_unlimited_respawns(void)
|
||||
{
|
||||
const char *value;
|
||||
|
||||
if (g_local_mp_mission_settings == NULL || g_lmp_datablock_get_str == NULL)
|
||||
return 0;
|
||||
value = g_lmp_datablock_get_str(g_local_mp_mission_settings + LMP_MIS_OFF_CUSTOM_BOTS, "wtoUnlimitedRespawns", "0");
|
||||
return value != NULL && strcmp(value, "1") == 0;
|
||||
}
|
||||
|
||||
static void finish_pending_spawn(uint8_t *mplayer)
|
||||
{
|
||||
const char *hero_name;
|
||||
|
||||
@@ -131,7 +146,9 @@ static void consume_pending_slot_if_spawned(uint8_t *mplayer)
|
||||
|
||||
if (g_pending_slot_id >= 0 && g_pending_slot_id < 32) {
|
||||
uint32_t bit = 1u << (uint32_t)g_pending_slot_id;
|
||||
if (g_pending_spare_type < 0)
|
||||
if (has_unlimited_respawns())
|
||||
local_mp_report_airfield_spawn(hero_name, g_pending_base_id);
|
||||
else if (g_pending_spare_type < 0)
|
||||
*(uint32_t *)(mplayer + LMP_MP_OFF_BROKEN_SLOTS_MASK) |= bit;
|
||||
else
|
||||
*(uint32_t *)(mplayer + LMP_MP_OFF_USED_SPARES_MASK) |= bit;
|
||||
@@ -140,6 +157,7 @@ static void consume_pending_slot_if_spawned(uint8_t *mplayer)
|
||||
*(uint32_t *)(mplayer + LMP_MP_OFF_BROKEN_SLOTS_MASK),
|
||||
*(uint32_t *)(mplayer + LMP_MP_OFF_USED_SPARES_MASK));
|
||||
g_pending_slot_id = -1;
|
||||
g_pending_base_id = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,12 +171,13 @@ static void __fastcall hook_gui_state_update(uint8_t *gui_state_obj, float dt)
|
||||
g_accept_pending = 0;
|
||||
g_respawn_dispatched = 0;
|
||||
g_pending_slot_id = -1;
|
||||
g_pending_base_id = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
bind_ai_mplayer_units();
|
||||
mplayer = g_local_mp_mplayer ? *g_local_mp_mplayer : NULL;
|
||||
consume_pending_slot_if_spawned(mplayer);
|
||||
finish_pending_spawn(mplayer);
|
||||
|
||||
if (g_accept_pending && gui_state_obj != NULL) {
|
||||
uint8_t *econ_state = local_mp_econ_state();
|
||||
@@ -185,7 +204,7 @@ static int64_t __fastcall hook_do_respawn_player(void *app)
|
||||
g_respawn_dispatched = 1;
|
||||
|
||||
result = orig_do_respawn(app);
|
||||
consume_pending_slot_if_spawned(mplayer);
|
||||
finish_pending_spawn(mplayer);
|
||||
bind_ai_mplayer_units();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ typedef struct LmpValueSpec {
|
||||
#define NUKE "local_mp_nuke"
|
||||
#define SUPPORT "local_mp_support"
|
||||
#define DAMAGE_NOTICES "local_mp_damage_notifications"
|
||||
#define AIR_EVENTS "local_mp_air_events"
|
||||
|
||||
static const LmpValueSpec SPECS[] = {
|
||||
A(CORE, "do_respawn_player", do_respawn_player), O(CORE, "do_respawn_player.app_score_rules", app_score_rules),
|
||||
@@ -65,6 +66,7 @@ static const LmpValueSpec SPECS[] = {
|
||||
O(CORE, "unit_info_name.unit_info", unit_info), O(CORE, "unit_info_name.info_name", unit_info_name),
|
||||
O(CORE, "unit_mplayer.unit_mplayer", unit_mplayer), O(CORE, "mission_custom_bots.custom_bots", mis_custom_bots),
|
||||
O(CORE, "mplayer_unit_eid.unit_eid", mp_unit_eid),
|
||||
A(CORE, "unit_on_event", unit_on_event),
|
||||
|
||||
A(PLAYERS, "mplayer_init_matching", mplayer_init_matching), A(PLAYERS, "is_slot_ready_at_host", is_slot_ready_at_host),
|
||||
O(PLAYERS, "mplayer_gui_state.gui_state", mp_gui_state), O(PLAYERS, "mplayer_used_spares.used_spares", mp_used_spares),
|
||||
@@ -76,7 +78,6 @@ static const LmpValueSpec SPECS[] = {
|
||||
A(LOADOUT, "datablock_dtor", datablock_dtor), A(LOADOUT, "bullet_vec_assign", bullet_vec_assign),
|
||||
A(LOADOUT, "get_decals_blk", get_decals_blk), A(LOADOUT, "get_attachables_blk", get_attachables_blk),
|
||||
A(LOADOUT, "str_hash_fnv1", str_hash_fnv1), A(LOADOUT, "namemap_add_name_id", namemap_add_name_id),
|
||||
A(LOADOUT, "crew_skills_init", crew_skills_init),
|
||||
O(LOADOUT, "refl_objects.bullets", refl_bullets), O(LOADOUT, "refl_objects.disabled_mods", refl_disabled_mods),
|
||||
O(LOADOUT, "refl_objects.enabled_mods", refl_enabled_mods), O(LOADOUT, "refl_objects.custom_preset", refl_custom_preset),
|
||||
O(LOADOUT, "refl_objects.attachables", refl_attachables), O(LOADOUT, "refl_objects.decals", refl_decals),
|
||||
@@ -91,7 +92,6 @@ static const LmpValueSpec SPECS[] = {
|
||||
O(LOADOUT, "change_req_slot.slot_id", econ_req_slot_id),
|
||||
O(LOADOUT, "change_req_bullets.bullets_begin", econ_req_bullets_begin),
|
||||
O(LOADOUT, "change_req_bullets.bullets_end", econ_req_bullets_end),
|
||||
O(LOADOUT, "unit_crew_skills.crew_skills", unit_crew_skills),
|
||||
|
||||
A(ACTIONS, "mp_init_chat", mp_init_chat), O(ACTIONS, "mp_chat.mp_chat", mp_chat),
|
||||
O(ACTIONS, "mp_team_countries.team1_countries", mp_team1_countries),
|
||||
@@ -153,11 +153,35 @@ static const LmpValueSpec SPECS[] = {
|
||||
A(DAMAGE_NOTICES, "hud_damage_deliver", hud_damage_deliver),
|
||||
A(DAMAGE_NOTICES, "avionics_damage", avionics_damage), O(DAMAGE_NOTICES, "avionics_damage.unit", avionics_unit),
|
||||
A(DAMAGE_NOTICES, "avionics_exit_optic.call", avionics_exit_optic),
|
||||
A(DAMAGE_NOTICES, "unit_on_event", unit_on_event), O(DAMAGE_NOTICES, "hit_event_offender.offender", hit_event_offender),
|
||||
O(DAMAGE_NOTICES, "hit_event_offender.offender", hit_event_offender),
|
||||
A(DAMAGE_NOTICES, "hit_watched_hero.watched_hero", watched_hero),
|
||||
A(DAMAGE_NOTICES, "hit_parts_feedback.enqueue_enemy_parts", enqueue_enemy_parts),
|
||||
A(DAMAGE_NOTICES, "hit_parts_feedback.hit_cam_important", hit_cam_important),
|
||||
A(DAMAGE_NOTICES, "hit_parts_feedback.naval_hit_state", naval_hit_state),
|
||||
|
||||
O(AIR_EVENTS, "mission_mode_name.mode_name", mis_mode_name),
|
||||
A(AIR_EVENTS, "prepare_local_mission", prepare_local_mission),
|
||||
A(AIR_EVENTS, "prepare_local_mission_clear.use_kill_streaks", use_kill_streaks),
|
||||
A(AIR_EVENTS, "kill_streak_rules.gameplay", gameplay),
|
||||
O(AIR_EVENTS, "kill_streak_rules.rule_count", gp_ks_rule_count),
|
||||
O(AIR_EVENTS, "kill_streak_rules.rules", gp_ks_rules),
|
||||
O(AIR_EVENTS, "kill_streak_rules.rule_tag", ks_rule_tag),
|
||||
A(AIR_EVENTS, "kill_streak_rules.name_map", kill_streak_name_map),
|
||||
A(AIR_EVENTS, "add_kill_streak_points", add_kill_streak_points),
|
||||
O(AIR_EVENTS, "mplayer_streak_progress.progress", mp_ks_progress),
|
||||
O(AIR_EVENTS, "kill_streak_ai_mults.air_ai_mult", ks_rule_air_ai_mult),
|
||||
O(AIR_EVENTS, "kill_streak_ai_mults.ground_ai_mult", ks_rule_ground_ai_mult),
|
||||
A(AIR_EVENTS, "air_event_spawn_table.battle_center", air_event_battle_center),
|
||||
O(AIR_EVENTS, "air_event_spawn_table.spawn_pos_count", ks_rule_spawn_pos_count),
|
||||
A(AIR_EVENTS, "air_event_spawn_table.max_rank", mission_max_rank),
|
||||
O(AIR_EVENTS, "air_event_spawn_table.spawn_pos", ks_rule_spawn_pos),
|
||||
O(AIR_EVENTS, "air_event_spawn_table.spawn_pos_stride", ks_spawn_pos_stride),
|
||||
O(AIR_EVENTS, "air_event_terrain.app_terrain", app_terrain),
|
||||
A(AIR_EVENTS, "air_event_terrain.terrain_height", air_event_terrain_height),
|
||||
A(AIR_EVENTS, "air_event_switch_unit", air_event_switch_unit),
|
||||
A(AIR_EVENTS, "air_event_orientation.call", air_event_orientation),
|
||||
A(AIR_EVENTS, "send_unit_respawn", send_unit_respawn),
|
||||
A(AIR_EVENTS, "send_unit_respawn_broadcast.mpi_sendto", mpi_sendto),
|
||||
};
|
||||
|
||||
static void store(const LmpValueSpec *spec, int64_t value, uint8_t *base)
|
||||
|
||||
@@ -17,7 +17,7 @@ typedef struct LmpValues {
|
||||
/* local_mp_core */
|
||||
uint8_t *do_respawn_player, *get_player_country, *refl_dtor, *aircraft_change_result, *set_player_gui_state;
|
||||
uint8_t *get_unit_by_eid, *set_owning_mplayer, *iground_on_dead, *datablock_get_str, *datablock_set_from;
|
||||
uint8_t *mp_construct_local, *gui_state_update, *unit_change_aircraft, *dagmem_alloc;
|
||||
uint8_t *mp_construct_local, *gui_state_update, *unit_change_aircraft, *dagmem_alloc, *unit_on_event;
|
||||
uint8_t *multiplayer, *app, *local_mplayer, *hero, *mission_settings, *stdmem, *player_count, *player_table;
|
||||
size_t mp_is_host, mp_is_local_mp, mp_chat_host, mp_pid, mp_user_id, mp_team, mp_broken_slots, mp_unit_eid;
|
||||
size_t match_team, app_score_rules, app_econ_holder, econ_state, econ_change_req;
|
||||
@@ -29,7 +29,7 @@ typedef struct LmpValues {
|
||||
|
||||
/* local_mp_loadout */
|
||||
uint8_t *sem_change_aircraft_send, *refl_ctor, *datablock_dtor, *bullet_vec_assign, *get_decals_blk;
|
||||
uint8_t *get_attachables_blk, *str_hash_fnv1, *namemap_add_name_id, *crew_skills_init;
|
||||
uint8_t *get_attachables_blk, *str_hash_fnv1, *namemap_add_name_id;
|
||||
size_t refl_bullets, refl_disabled_mods, refl_enabled_mods, refl_custom_preset, refl_attachables, refl_decals;
|
||||
size_t refl_custom_skin, refl_skin, refl_weapon, refl_unit, refl_flags, refl_gun_convergence;
|
||||
size_t refl_vertical_targeting, refl_bomb_fuse, refl_fuel;
|
||||
@@ -37,7 +37,6 @@ typedef struct LmpValues {
|
||||
/* Change request members: captured as offsets in the economic state, used relative to the request. */
|
||||
size_t econ_req_slot_id, econ_req_bullets_begin, econ_req_bullets_end;
|
||||
size_t req_slot_id, req_bullets_begin, req_bullets_end;
|
||||
size_t unit_crew_skills;
|
||||
|
||||
/* local_mp_actions */
|
||||
uint8_t *mp_init_chat;
|
||||
@@ -78,8 +77,15 @@ typedef struct LmpValues {
|
||||
/* local_mp_damage_notifications */
|
||||
uint8_t *barrel_damage, *breech_fire_update, *barrel_notice_deliver, *breech_notice_deliver, *mplayer_controlled_unit;
|
||||
uint8_t *hud_damage_deliver, *avionics_damage, *avionics_exit_optic;
|
||||
uint8_t *unit_on_event, *watched_hero, *enqueue_enemy_parts, *hit_cam_important, *naval_hit_state;
|
||||
uint8_t *watched_hero, *enqueue_enemy_parts, *hit_cam_important, *naval_hit_state;
|
||||
size_t barrel_unit_ref, breech_unit, barrel_notice_id, breech_notice_id, avionics_unit, hit_event_offender;
|
||||
|
||||
/* local_mp_air_events */
|
||||
uint8_t *prepare_local_mission, *use_kill_streaks, *gameplay, *kill_streak_name_map, *add_kill_streak_points;
|
||||
uint8_t *air_event_battle_center, *mission_max_rank, *air_event_terrain_height, *air_event_switch_unit;
|
||||
uint8_t *air_event_orientation, *send_unit_respawn, *mpi_sendto;
|
||||
size_t mis_mode_name, gp_ks_rules, gp_ks_rule_count, ks_rule_tag, ks_rule_air_ai_mult, ks_rule_ground_ai_mult;
|
||||
size_t ks_rule_spawn_pos, ks_rule_spawn_pos_count, ks_spawn_pos_stride, mp_ks_progress, app_terrain;
|
||||
} LmpValues;
|
||||
|
||||
extern LmpValues g_lmp;
|
||||
|
||||
@@ -21,6 +21,7 @@ import { localEndpoint, type LocalEndpoint } from './network/local-endpoint.ts';
|
||||
import { NETWORK_HOOK_LIBRARY, networkHookSettings } from './network/network-hook.ts';
|
||||
import { loadNativeModules } from './native/native-definition.ts';
|
||||
import { resolveNativeModules } from './native/native-resolve.ts';
|
||||
import type { AddedFile } from './pack-edit.ts';
|
||||
import { patchSetFolders } from './patch-set.ts';
|
||||
import { offlinePackBundleGuids } from './store/offline-bundles.ts';
|
||||
|
||||
@@ -44,6 +45,8 @@ export interface GameCopyInputs {
|
||||
readonly multiVehiclePackIds: readonly string[];
|
||||
/** Store the placeholder decal index; false when the player's own web cache is copied. */
|
||||
readonly placeholderDecals: boolean;
|
||||
/** Real dldata/downloadable_decals.blk and downloadable_skins.blk extracted from the player's cache. */
|
||||
readonly decalIndexFiles?: readonly AddedFile[];
|
||||
/** Whether wto_ws.dll writes win64/wto_ws.log; defaults to true. */
|
||||
readonly hookLogging?: boolean;
|
||||
}
|
||||
@@ -92,6 +95,7 @@ export function buildGameCopy(inputs: GameCopyInputs): GameCopyBuild {
|
||||
appliedGuiPatches.includes('registration/keep-local-page-embedded');
|
||||
const { pack: charPack, ...charReport } = rebuildCharPack(inputs.stock.charPack, endpoint, {
|
||||
placeholderDecals: inputs.placeholderDecals,
|
||||
...(inputs.decalIndexFiles ? { decalIndexFiles: inputs.decalIndexFiles } : {}),
|
||||
localRegistration,
|
||||
});
|
||||
const bundles = offlinePackBundleGuids(inputs.stock.charPack, inputs.multiVehiclePackIds);
|
||||
|
||||
@@ -8,7 +8,7 @@ import { DECALS_CONFIG_PATH, offlineDecalIndex } from './decals/offline-decal-in
|
||||
import { enableFeaturesForEveryone, GAME_SETTINGS_PATH, OFFLINE_FEATURES } from './features/offline-features.ts';
|
||||
import type { LocalEndpoint } from './network/local-endpoint.ts';
|
||||
import { redirectNetworkConfig, type NetworkRedirectReport } from './network/redirect-network-config.ts';
|
||||
import { editPackBlks, readPackBlk } from './pack-edit.ts';
|
||||
import { editPackBlks, readPackBlk, type AddedFile } from './pack-edit.ts';
|
||||
import { revealHiddenVehicles, SHOP_PATH } from './tech-tree/reveal-hidden-vehicles.ts';
|
||||
|
||||
export const NETWORK_CONFIG_PATH = 'config/network.blk';
|
||||
@@ -20,13 +20,15 @@ export interface CharPackResult {
|
||||
readonly features: readonly string[];
|
||||
/** Vehicles that were hidden from players who had not researched or bought them. */
|
||||
readonly revealedVehicles: number;
|
||||
/** Decals in the placeholder index; undefined when the index was left out. */
|
||||
/** Decals in the placeholder index; undefined when the player's own decal cache is used. */
|
||||
readonly placeholderDecals: number | undefined;
|
||||
}
|
||||
|
||||
export interface CharPackOptions {
|
||||
/** Store the placeholder decal index (false when the player's own web cache is copied). */
|
||||
readonly placeholderDecals: boolean;
|
||||
/** Real dldata/downloadable_decals.blk and downloadable_skins.blk extracted from the player's cache. */
|
||||
readonly decalIndexFiles?: readonly AddedFile[];
|
||||
readonly localRegistration: boolean;
|
||||
}
|
||||
|
||||
@@ -34,11 +36,15 @@ export function rebuildCharPack(stockPack: Uint8Array, endpoint: LocalEndpoint,
|
||||
let network: NetworkRedirectReport | undefined;
|
||||
let features: string[] = [];
|
||||
let revealedVehicles = 0;
|
||||
const decals = options.placeholderDecals ? offlineDecalIndex(readPackBlk(stockPack, DECALS_CONFIG_PATH)) : undefined;
|
||||
const usePlayerIndex = (options.decalIndexFiles?.length ?? 0) > 0;
|
||||
const decals = !usePlayerIndex && options.placeholderDecals
|
||||
? offlineDecalIndex(readPackBlk(stockPack, DECALS_CONFIG_PATH))
|
||||
: undefined;
|
||||
const addedFiles = usePlayerIndex ? options.decalIndexFiles! : (decals?.files ?? []);
|
||||
const pack = editPackBlks(stockPack, [
|
||||
{ path: NETWORK_CONFIG_PATH, edit: (root) => { network = redirectNetworkConfig(root, endpoint, options.localRegistration); } },
|
||||
{ path: GAME_SETTINGS_PATH, edit: (root) => { features = enableFeaturesForEveryone(root, OFFLINE_FEATURES); } },
|
||||
{ path: SHOP_PATH, edit: (root) => { revealedVehicles = revealHiddenVehicles(root); } },
|
||||
], decals?.files ?? []);
|
||||
], addedFiles);
|
||||
return { pack, network: network!, features, revealedVehicles, placeholderDecals: decals?.decals };
|
||||
}
|
||||
@@ -1,47 +1,98 @@
|
||||
/**
|
||||
* Decals from the player's own online client: the player names the web cache folder of an
|
||||
* installation they have played online with (<game>/cache/content), and the build copies it
|
||||
* into the game copy's cache/content. The offline version never looks for that folder itself.
|
||||
* Decals and downloadable skins from the player's own online client: the player names the web
|
||||
* cache folder of an installation they have played online with (<game>/cache/content, or its
|
||||
* parent <game>/cache), and the build copies the cached textures into the game copy's
|
||||
* cache/content. The offline version never looks for that folder itself.
|
||||
*
|
||||
* What the copy gives the client (aces.exe 2.61.0.37):
|
||||
* - cache/content/ is the web cache root ("ContentProvider::init mount=<game>/cache/content/").
|
||||
* - dldata_s.info names the current indexes; when the request for it fails, the client reads
|
||||
* the cached copy ("failed to get dlContent index hashes from %s, will fallback local copy",
|
||||
* 0xd3eb40), and the local server answers that request with 404.
|
||||
* - downloadable_decals.<hash>.blk is the decal index as the CDN served it, with its signature
|
||||
* (0xd383e0 checks it and deletes a file that fails). If the file named by dldata_s.info is
|
||||
* missing, the newest valid downloadable_decals.*.blk in the folder is used (0xd3f610).
|
||||
* - Each decal's texture is fetched through the web cache by its lod0 name (0xd44fc0); the
|
||||
* textures the player's client has cached are in the copied folder (assumed, not verified
|
||||
* against an online cache: the folder layout below httpCache/ was not examined). Textures it
|
||||
* never cached cannot be fetched offline and stay blank.
|
||||
*
|
||||
* With a player source the build leaves the vromfs index (offline-decal-index.ts) out of
|
||||
* char.vromfs.bin, because the client takes the vromfs index first and then skips the web cache.
|
||||
* Two layouts exist across War Thunder builds (verified on 2.61.0.37 and 2.61.0.58):
|
||||
* 1. Modern vromfs-indexed cache (2.61+): cache/content/ holds dldata_s.info and the downloaded
|
||||
* <first2>/<hash>.ddsx textures, while the decal and skin indexes (dldata/downloadable_decals.blk
|
||||
* and dldata/downloadable_skins.blk) ship inside sibling cache/binary.<ver>/regional.vromfs.bin
|
||||
* (mounted by webdlcontent::on_regional_vrom_remounted, 0xd3cf95 -> 0xd3d066). Because the client
|
||||
* reads the vromfs index first, it never writes downloadable_decals.<hash>.blk into cache/content/.
|
||||
* We extract both index BLKs into a self-contained snapshot (.wto-index/) on import and embed
|
||||
* them into char.vromfs.bin during build so webdlcontent::init mounts cache/content/ (0xd3ca11)
|
||||
* and loads the real hashes from vromfs without signature checks (0xd3cb6b).
|
||||
* 2. Legacy webcache-indexed cache: cache/content/ holds dldata_s.info and signed
|
||||
* downloadable_decals.<hash>.blk directly; char.vromfs.bin omits dldata/ so the client reads
|
||||
* the cached index from cache/content/.
|
||||
*/
|
||||
import { cpSync, existsSync, lstatSync, readdirSync, realpathSync, statSync } from 'node:fs';
|
||||
import { dirname, isAbsolute, join, relative, sep } from 'node:path';
|
||||
import { cpSync, existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, realpathSync, statSync, writeFileSync } from 'node:fs';
|
||||
import { basename, dirname, isAbsolute, join, relative, sep } from 'node:path';
|
||||
import { decodeBlk, emptyBlock, encodeBlk, parseSharedNameMap } from '@wto/blk';
|
||||
import { getFile, NAME_MAP_PATH, readArchive } from '@wto/vromfs';
|
||||
import type { AddedFile } from '../pack-edit.ts';
|
||||
import { compareVersions } from '../version-record.ts';
|
||||
import { DECALS_INDEX_PATH, SKINS_INDEX_PATH } from './offline-decal-index.ts';
|
||||
|
||||
export const WEB_CACHE_FOLDER = join('cache', 'content');
|
||||
const INDEX_LIST_FILE = 'dldata_s.info';
|
||||
const DECALS_INDEX_FILE = /^downloadable_decals\.[a-z2-7]{32}-[a-z2-7]{1,8}\.blk$/;
|
||||
const BINARY_CACHE_DIR = /^binary\.(.+)$/;
|
||||
const REGIONAL_PACK_NAME = 'regional.vromfs.bin';
|
||||
const SNAPSHOT_INDEX_DIR = '.wto-index';
|
||||
const SNAPSHOT_DECALS_FILE = 'downloadable_decals.blk';
|
||||
const SNAPSHOT_SKINS_FILE = 'downloadable_skins.blk';
|
||||
|
||||
export interface PlayerDecalCache {
|
||||
readonly copiedTo: string;
|
||||
readonly decalIndexes: readonly string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the actual cache/content folder when the player selects either <game>/cache/content
|
||||
* or its parent <game>/cache folder.
|
||||
*/
|
||||
export function resolvePlayerDecalCacheFolder(source: string): string {
|
||||
if (!existsSync(source) || !statSync(source).isDirectory()) return source;
|
||||
if (directDecalCacheProblem(source) === undefined) return source;
|
||||
const nested = join(source, 'content');
|
||||
if (existsSync(nested) && statSync(nested).isDirectory() && directDecalCacheProblem(nested) === undefined) {
|
||||
return nested;
|
||||
}
|
||||
return source;
|
||||
}
|
||||
|
||||
/** Check that the folder looks like an online client's web cache; returns the problem or undefined. */
|
||||
export function playerDecalCacheProblem(source: string): string | undefined {
|
||||
if (!existsSync(source) || !statSync(source).isDirectory()) return `${source} is not a folder`;
|
||||
if (!statSync(join(source, INDEX_LIST_FILE), { throwIfNoEntry: false })?.isFile()) return `${source} has no ${INDEX_LIST_FILE} (expected the cache/content folder of an online installation)`;
|
||||
if (decalIndexes(source).length === 0) return `${source} has no downloadable_decals.<hash>.blk`;
|
||||
return undefined;
|
||||
const resolved = resolvePlayerDecalCacheFolder(source);
|
||||
return directDecalCacheProblem(resolved);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read real dldata/downloadable_decals.blk and dldata/downloadable_skins.blk for embedding into
|
||||
* char.vromfs.bin when the cache uses either an imported snapshot index or a sibling
|
||||
* binary.<ver>/regional.vromfs.bin. Returns undefined for legacy downloadable_decals.<hash>.blk
|
||||
* caches, which supply their index directly inside cache/content/.
|
||||
*/
|
||||
export function readPlayerDecalIndexFiles(source: string): readonly AddedFile[] | undefined {
|
||||
const folder = resolvePlayerDecalCacheFolder(source);
|
||||
const snapshot = readSnapshotIndexFiles(folder);
|
||||
if (snapshot) return snapshot;
|
||||
if (decalIndexes(folder).length > 0) return undefined;
|
||||
const regional = findRegionalPack(folder);
|
||||
if (!regional) return undefined;
|
||||
return extractRegionalIndexFiles(regional);
|
||||
}
|
||||
|
||||
/**
|
||||
* Persist extracted vromfs decal/skin indexes into an imported cache snapshot so subsequent
|
||||
* launches are completely self-contained and never touch the online client directory.
|
||||
*/
|
||||
export function writeDecalCacheIndexSnapshot(source: string, target: string): void {
|
||||
const files = readPlayerDecalIndexFiles(source);
|
||||
if (!files) return;
|
||||
const indexDir = join(target, SNAPSHOT_INDEX_DIR);
|
||||
mkdirSync(indexDir, { recursive: true });
|
||||
for (const file of files) {
|
||||
const fileName = file.path === DECALS_INDEX_PATH ? SNAPSHOT_DECALS_FILE : SNAPSHOT_SKINS_FILE;
|
||||
writeFileSync(join(indexDir, fileName), file.content);
|
||||
}
|
||||
}
|
||||
|
||||
/** Copy the player's web cache folder into <copy>/cache/content; the source is only read. */
|
||||
export function copyPlayerDecalCache(source: string, copyFolder: string): PlayerDecalCache {
|
||||
const from = realpathSync(source);
|
||||
const from = realpathSync(resolvePlayerDecalCacheFolder(source));
|
||||
const target = join(realpathSync(copyFolder), WEB_CACHE_FOLDER);
|
||||
if (contains(from, target) || contains(target, from)) {
|
||||
throw new Error('The decal source and game copy cache overlap.');
|
||||
@@ -49,10 +100,12 @@ export function copyPlayerDecalCache(source: string, copyFolder: string): Player
|
||||
if (lstatSync(dirname(target), { throwIfNoEntry: false })?.isSymbolicLink()) {
|
||||
throw new Error('The game cache folder is redirected.');
|
||||
}
|
||||
const snapshotDir = join(from, SNAPSHOT_INDEX_DIR);
|
||||
cpSync(from, target, {
|
||||
recursive: true,
|
||||
force: true,
|
||||
filter: (input, output) => {
|
||||
if (input === snapshotDir || input.startsWith(snapshotDir + sep)) return false;
|
||||
const entry = lstatSync(input);
|
||||
const existing = lstatSync(output, { throwIfNoEntry: false });
|
||||
if ((!entry.isFile() && !entry.isDirectory()) || existing?.isSymbolicLink() ||
|
||||
@@ -62,7 +115,94 @@ export function copyPlayerDecalCache(source: string, copyFolder: string): Player
|
||||
return true;
|
||||
},
|
||||
});
|
||||
return { copiedTo: target, decalIndexes: decalIndexes(from) };
|
||||
const legacy = decalIndexes(from);
|
||||
const indexLabels = legacy.length > 0
|
||||
? legacy
|
||||
: (readSnapshotIndexFiles(from) || findRegionalPack(from) ? [DECALS_INDEX_PATH, SKINS_INDEX_PATH] : []);
|
||||
return { copiedTo: target, decalIndexes: indexLabels };
|
||||
}
|
||||
|
||||
function directDecalCacheProblem(folder: string): string | undefined {
|
||||
if (!existsSync(folder) || !statSync(folder).isDirectory()) return `${folder} is not a folder`;
|
||||
if (readSnapshotIndexFiles(folder)) return undefined;
|
||||
if (statSync(join(folder, INDEX_LIST_FILE), { throwIfNoEntry: false })?.isFile() && decalIndexes(folder).length > 0) {
|
||||
return undefined;
|
||||
}
|
||||
const hasTextures = hasCachedDdsxTextures(folder);
|
||||
const regional = findRegionalPack(folder);
|
||||
if (hasTextures && regional) return undefined;
|
||||
if (!hasTextures && !regional) {
|
||||
return `${folder} has neither cached .ddsx textures nor downloadable_decals.<hash>.blk (log into the online hangar once to populate cache/content)`;
|
||||
}
|
||||
if (!hasTextures) {
|
||||
return `${folder} has no cached .ddsx textures yet (log into the online hangar once to cache decals or skins)`;
|
||||
}
|
||||
return `${folder} has no downloadable_decals.<hash>.blk and no sibling binary.*/${REGIONAL_PACK_NAME}`;
|
||||
}
|
||||
|
||||
function readSnapshotIndexFiles(folder: string): readonly AddedFile[] | undefined {
|
||||
const decalsPath = join(folder, SNAPSHOT_INDEX_DIR, SNAPSHOT_DECALS_FILE);
|
||||
if (!statSync(decalsPath, { throwIfNoEntry: false })?.isFile()) return undefined;
|
||||
const skinsPath = join(folder, SNAPSHOT_INDEX_DIR, SNAPSHOT_SKINS_FILE);
|
||||
const skinsContent = statSync(skinsPath, { throwIfNoEntry: false })?.isFile()
|
||||
? readFileSync(skinsPath)
|
||||
: encodeBlk(emptyBlock());
|
||||
return [
|
||||
{ path: SKINS_INDEX_PATH, content: skinsContent },
|
||||
{ path: DECALS_INDEX_PATH, content: readFileSync(decalsPath) },
|
||||
];
|
||||
}
|
||||
|
||||
function hasCachedDdsxTextures(folder: string): boolean {
|
||||
for (const entry of readdirSync(folder, { withFileTypes: true })) {
|
||||
if (!entry.isDirectory() || entry.name === SNAPSHOT_INDEX_DIR) continue;
|
||||
const sub = join(folder, entry.name);
|
||||
for (const child of readdirSync(sub, { withFileTypes: true })) {
|
||||
if (child.isFile() && child.name.endsWith('.ddsx')) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function findRegionalPack(contentFolder: string): string | undefined {
|
||||
const parent = dirname(contentFolder);
|
||||
if (parent === contentFolder || !existsSync(parent)) return undefined;
|
||||
const candidates: Array<{ readonly path: string; readonly version: string; readonly mtimeMs: number }> = [];
|
||||
for (const entry of readdirSync(parent, { withFileTypes: true })) {
|
||||
if (!entry.isDirectory() || entry.isSymbolicLink()) continue;
|
||||
const match = BINARY_CACHE_DIR.exec(entry.name);
|
||||
if (!match) continue;
|
||||
const packPath = join(parent, entry.name, REGIONAL_PACK_NAME);
|
||||
const stat = lstatSync(packPath, { throwIfNoEntry: false });
|
||||
if (!stat || !stat.isFile() || stat.isSymbolicLink()) continue;
|
||||
candidates.push({ path: packPath, version: match[1]!, mtimeMs: stat.mtimeMs });
|
||||
}
|
||||
candidates.sort((a, b) => compareVersions(b.version, a.version) || b.mtimeMs - a.mtimeMs || basename(b.path).localeCompare(basename(a.path)));
|
||||
for (const candidate of candidates) {
|
||||
try {
|
||||
const archive = readArchive(readFileSync(candidate.path));
|
||||
if (archive.files.has(DECALS_INDEX_PATH)) return candidate.path;
|
||||
} catch {
|
||||
// Skip unreadable or partially written regional packs and try older ones.
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function extractRegionalIndexFiles(regionalPackPath: string): readonly AddedFile[] {
|
||||
const archive = readArchive(readFileSync(regionalPackPath));
|
||||
const dictionaries = [...archive.files.keys()].filter((path) => path.endsWith('.dict'));
|
||||
const dictionary = dictionaries.length === 1 ? archive.files.get(dictionaries[0]!) : undefined;
|
||||
const names = archive.files.has(NAME_MAP_PATH) ? parseSharedNameMap(getFile(archive, NAME_MAP_PATH), dictionary).names : [];
|
||||
const shared = { names, dictionary };
|
||||
const decalsBlk = decodeBlk(getFile(archive, DECALS_INDEX_PATH), shared);
|
||||
const skinsBlk = archive.files.has(SKINS_INDEX_PATH)
|
||||
? decodeBlk(getFile(archive, SKINS_INDEX_PATH), shared)
|
||||
: emptyBlock();
|
||||
return [
|
||||
{ path: SKINS_INDEX_PATH, content: encodeBlk(skinsBlk) },
|
||||
{ path: DECALS_INDEX_PATH, content: encodeBlk(decalsBlk) },
|
||||
];
|
||||
}
|
||||
|
||||
function contains(parent: string, child: string): boolean {
|
||||
|
||||
@@ -13,7 +13,13 @@ export {
|
||||
type StockGameFiles,
|
||||
} from './build-game-copy.ts';
|
||||
export { NETWORK_CONFIG_PATH, rebuildCharPack, type CharPackResult } from './char-pack.ts';
|
||||
export { copyPlayerDecalCache, playerDecalCacheProblem } from './decals/player-decal-cache.ts';
|
||||
export {
|
||||
copyPlayerDecalCache,
|
||||
playerDecalCacheProblem,
|
||||
readPlayerDecalIndexFiles,
|
||||
resolvePlayerDecalCacheFolder,
|
||||
writeDecalCacheIndexSnapshot,
|
||||
} from './decals/player-decal-cache.ts';
|
||||
export { blockingFailures, ESSENTIAL_FEATURES } from './essential-features.ts';
|
||||
export { patchExecutable, type ExecutableResult } from './executable.ts';
|
||||
export { assertWritableCopy, GAME_FILES, isInSteamLibrary, type WritableCopyOptions } from './game-copy.ts';
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
// Let Unit::loadCrew read the local player's equipped crew when the multiplayer host is LocalMP.
|
||||
// Why the exe: native initialization skips the profile on hosts before it builds the live crew object.
|
||||
// Without it: a human player's LocalMP unit receives default skills instead of the crew in the profile.
|
||||
{
|
||||
"id": "battle/load-local-host-player-crew",
|
||||
"title": "Load the equipped player's crew on a LocalMP host",
|
||||
"features": ["E-Crew skills in battle"],
|
||||
"requires": [],
|
||||
"variants": [
|
||||
// Unit::loadCrew tests the host flag, then the unit's player bit and the local player ID.
|
||||
// The adjacent host and LocalMP fields are boolean bytes at +0x60 and +0x61 in Multiplayer.
|
||||
// Keep the owner checks and skip to the default crew only for a non-LocalMP host.
|
||||
// 2.61.0.37: site 0x10025d6, edit at 0x10025dd; 2.61.0.58: edit at 0x100700d.
|
||||
{
|
||||
"written_for": "2.61.0.37",
|
||||
"locate": {
|
||||
"method": "signature",
|
||||
"section": ".text",
|
||||
"pattern": "48 8b 05 ?? ?? ?? ?? 48 85 c0 74 0a 80 78 60 00 0f 85 ?? ?? ?? ?? 8b 86 90 00 00 00 a9 00 01 00 00 75 15 48 8b 05 ?? ?? ?? ?? 8b 80 a4 05 00 00 39 c5",
|
||||
"captures": {
|
||||
"default_crew": { "offset": 18, "type": "rel32" }
|
||||
}
|
||||
},
|
||||
"edit": {
|
||||
"offset": 7,
|
||||
"asm": [
|
||||
"test rax, rax",
|
||||
"je check_owner",
|
||||
"cmp word ptr [rax + 0x60], 1",
|
||||
"je {default_crew}",
|
||||
"check_owner:",
|
||||
"test byte ptr [rsi + 0x91], 1",
|
||||
"nop",
|
||||
"nop",
|
||||
"nop"
|
||||
],
|
||||
"bytes": "48 85 c0 74 0b 66 83 78 60 01 0f 84 ?? ?? ?? ?? f6 86 91 00 00 00 01 90 90 90",
|
||||
"expect_original": "48 85 c0 74 0a 80 78 60 00 0f 85 ?? ?? ?? ?? 8b 86 90 00 00 00 a9 00 01 00 00",
|
||||
"fixups": [{ "at": 12, "type": "rel32", "target": "default_crew" }]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
let missionState = get_mission_custom_state(false)
|
||||
let economicName = missionState?.matchingEconomicName ?? ""
|
||||
let tag = missionState?.matchingTag ?? ""
|
||||
if (economicName == "" && tag == "")
|
||||
return false
|
||||
@@ -0,0 +1,4 @@
|
||||
let missionState = get_mission_custom_state(false)
|
||||
let economicName = missionState?.matchingEconomicName ?? ""
|
||||
let tag = missionState?.matchingTag ?? ""
|
||||
local minRank = 0
|
||||
@@ -0,0 +1,3 @@
|
||||
function isWeaponVisible(unit, weapon, onlySelectable = true, weaponTags = null) {
|
||||
if (weapon?.hideInGui || isWeaponAux(weapon))
|
||||
return false
|
||||
@@ -0,0 +1,23 @@
|
||||
// Restrict extra LocalMP battle slots to the weapon presets chosen for the active mode,
|
||||
// and fall back to LocalMP launch metadata for GameModeRestrictions when mission custom state is empty.
|
||||
// Why the client: online the battle server filters slot presets and fills mission custom state;
|
||||
// on a LocalMP host, killstreak nuclear carriers carry both Ground RB and Nuclear Escalation presets.
|
||||
// Without it: Nuclear Escalation carriers expose Ground RB presets with zero nuclear yield at stage 0.
|
||||
{
|
||||
"id": "battle/filter-extra-slot-weapons",
|
||||
"title": "Filter weapon presets of LocalMP extra battle slots and mode restrictions",
|
||||
"features": [
|
||||
"K-Additional vehicles"
|
||||
],
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.37",
|
||||
"file": "scripts/weaponry/weaponryinfo.nut",
|
||||
"edits": [
|
||||
{ "find": "find-visible.nut", "replace": "replace-visible.nut" },
|
||||
{ "find": "find-min-rank.nut", "replace": "replace-min-rank.nut" },
|
||||
{ "find": "find-allowed-modes.nut", "replace": "replace-allowed-modes.nut" }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
let missionState = get_mission_custom_state(false)
|
||||
let wtoBattle = require("nestdb").ndbTryRead(["wto", "activeBattle"])
|
||||
let economicName = (missionState?.matchingEconomicName ?? "") != ""
|
||||
? missionState.matchingEconomicName
|
||||
: (wtoBattle?.economicName ?? "")
|
||||
let tag = (missionState?.matchingTag ?? "") != ""
|
||||
? missionState.matchingTag
|
||||
: (wtoBattle?.modeTag ?? "")
|
||||
if (economicName == "" && tag == "")
|
||||
return false
|
||||
@@ -0,0 +1,9 @@
|
||||
let missionState = get_mission_custom_state(false)
|
||||
let wtoBattle = require("nestdb").ndbTryRead(["wto", "activeBattle"])
|
||||
let economicName = (missionState?.matchingEconomicName ?? "") != ""
|
||||
? missionState.matchingEconomicName
|
||||
: (wtoBattle?.economicName ?? "")
|
||||
let tag = (missionState?.matchingTag ?? "") != ""
|
||||
? missionState.matchingTag
|
||||
: (wtoBattle?.modeTag ?? "")
|
||||
local minRank = 0
|
||||
@@ -0,0 +1,18 @@
|
||||
function isWeaponVisible(unit, weapon, onlySelectable = true, weaponTags = null) {
|
||||
if (weapon?.hideInGui || isWeaponAux(weapon))
|
||||
return false
|
||||
|
||||
// WTOffline: restrict extra battle slots (e.g. Nuclear Escalation carriers) to their mode presets.
|
||||
if (isInFlight() && unit != null && weapon != null) {
|
||||
let wtoExtraSlots = require("nestdb").ndbTryRead(["wto", "activeBattle"])?.extraBattleSlots
|
||||
if (wtoExtraSlots != null) {
|
||||
foreach (wtoSlot in wtoExtraSlots) {
|
||||
let wtoAllowed = wtoSlot?.allowedWeapons
|
||||
if (wtoSlot?.unitName == unit.name && wtoAllowed != null && wtoAllowed.len() > 0) {
|
||||
if (wtoAllowed.indexof(weapon.name) == null)
|
||||
return false
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,18 +18,68 @@
|
||||
requestData.weapon = wtoExtraSlot.forceWeapon
|
||||
let wtoSlotMods = wtoExtraSlot?.modifications ?? []
|
||||
let wtoUnit = getAircraftByName(wtoUnitName) ?? this.getCurSlotUnit()
|
||||
let wtoGlobalModsBlk = require("blkGetters").get_modifications_blk()?.modifications
|
||||
let wtoUnitModsBlk = wtoUnitName != ""
|
||||
? require("%scripts/unit/unitParams.nut").getFullUnitBlk(wtoUnitName)?.modifications
|
||||
: null
|
||||
// Only the bulletMod belts chosen in this spawn request may enter enabledMods; sending every
|
||||
// unlocked belt lets the last belt in wpcost.blk (usually stealth) overwrite single-belt guns.
|
||||
let wtoSelectedBullets = {}
|
||||
for (local wtoBi = 0; wtoBi < BULLETS_SETS_QUANTITY; wtoBi++) {
|
||||
let wtoBulName = requestData?[$"bullets{wtoBi}"] ?? ""
|
||||
if (wtoBulName != "")
|
||||
wtoSelectedBullets[wtoBulName] <- true
|
||||
}
|
||||
let wtoModNames = []
|
||||
let wtoSeenMods = {}
|
||||
foreach (wtoMod in (wtoUnit?.getModifications() ?? [])) {
|
||||
let wtoName = wtoMod?.name ?? ""
|
||||
if (wtoName != "" && !(wtoName in wtoSeenMods)) {
|
||||
wtoSeenMods[wtoName] <- true
|
||||
wtoModNames.append(wtoName)
|
||||
}
|
||||
}
|
||||
if (wtoUnitModsBlk != null) {
|
||||
for (local wtoMi = 0; wtoMi < wtoUnitModsBlk.blockCount(); wtoMi++) {
|
||||
let wtoName = wtoUnitModsBlk.getBlock(wtoMi).getBlockName()
|
||||
if (wtoName != "" && !(wtoName in wtoSeenMods)) {
|
||||
wtoSeenMods[wtoName] <- true
|
||||
wtoModNames.append(wtoName)
|
||||
}
|
||||
}
|
||||
}
|
||||
let wtoEnabledMods = []
|
||||
let wtoDisabledMods = []
|
||||
foreach (wtoMod in (wtoUnit?.getModifications() ?? [])) {
|
||||
let wtoModName = wtoMod?.name ?? ""
|
||||
if (wtoModName == "")
|
||||
continue
|
||||
foreach (wtoModName in wtoModNames) {
|
||||
let wtoIsEnabled = wtoExtraSlot == null
|
||||
? wtoChardRes.shopIsModificationEnabled(wtoUnitName, wtoModName)
|
||||
: (wtoExtraSlot?.allModifications == true || wtoSlotMods.contains(wtoModName))
|
||||
if (wtoIsEnabled)
|
||||
let wtoGlobalModBlk = wtoGlobalModsBlk?.getBlockByName(wtoModName)
|
||||
let wtoUnitModBlk = wtoUnitModsBlk?.getBlockByName(wtoModName)
|
||||
let wtoHasBulletMod = (wtoUnitModBlk?.getBlockByName("effects")?.paramExists("bulletMod") ?? false)
|
||||
|| (wtoGlobalModBlk?.getBlockByName("effects")?.paramExists("bulletMod") ?? false)
|
||||
if (wtoHasBulletMod) {
|
||||
if (wtoIsEnabled && (wtoModName in wtoSelectedBullets))
|
||||
wtoEnabledMods.append(wtoModName)
|
||||
continue
|
||||
}
|
||||
// Match UnitModifications::initFromSave / initFromLists: invertEnableLogic mods encode stock
|
||||
// penalties in effects{} and must move to disabledMods once enabled; normal unequipped mods
|
||||
// only enter disabledMods when they define disableModEffects{}.
|
||||
local wtoInvert = wtoGlobalModBlk?.getBool("invertEnableLogic", false) ?? false
|
||||
if (wtoUnitModBlk != null)
|
||||
wtoInvert = wtoUnitModBlk.getBool("invertEnableLogic", wtoInvert)
|
||||
let wtoHasDisableEffects = wtoUnitModBlk?.getBlockByName("disableModEffects") != null
|
||||
|| wtoGlobalModBlk?.getBlockByName("disableModEffects") != null
|
||||
if (wtoInvert) {
|
||||
if (wtoIsEnabled)
|
||||
wtoDisabledMods.append(wtoModName)
|
||||
else
|
||||
wtoEnabledMods.append(wtoModName)
|
||||
}
|
||||
else if (wtoIsEnabled)
|
||||
wtoEnabledMods.append(wtoModName)
|
||||
else if (wtoExtraSlot == null && wtoChardRes.shopIsModificationPurchased(wtoUnitName, wtoModName))
|
||||
else if (wtoHasDisableEffects)
|
||||
wtoDisabledMods.append(wtoModName)
|
||||
}
|
||||
let wtoBlk = DataBlock()
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
function getPerBaseRespawnDelays(respawnBasesList, unitName) {
|
||||
local baseDelays = {}
|
||||
if ((get_current_mission_info_cached()?.afterRespawnDelaySec ?? 0) <= 0)
|
||||
return baseDelays
|
||||
foreach (spawn in respawnBasesList)
|
||||
if (isPerBaseDelayRow(spawn))
|
||||
baseDelays[spawn.id] <- get_slot_delay(unitName, spawn.id)
|
||||
return baseDelays
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
function onEventLoadingStateChange(_p) {
|
||||
if (!isInFlight())
|
||||
this.resetSelectedBase()
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// Track successful departures by aircraft and airfield for the stock respawn base list.
|
||||
// The LocalMP host has the actual spawn result. The local matching service only starts the mission.
|
||||
// The stock delay getters read a flight server snapshot, so the LocalMP departure event supplies it.
|
||||
{
|
||||
"id": "battle/track-local-airfield-departures",
|
||||
"title": "Track LocalMP departures for airfield respawn delays",
|
||||
"features": ["K-Spawn score and respawns"],
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.58",
|
||||
"file": "scripts/respawn/respawnbases.nut",
|
||||
"edits": [
|
||||
{ "find": "find-delays.nut", "replace": "replace-delays.nut" },
|
||||
{ "find": "find-loading.nut", "replace": "replace-loading.nut" }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
wtoAirfieldDepartures = {}
|
||||
|
||||
function hasLocalRespawnDelays() {
|
||||
return this.wtoAirfieldDepartures.len() > 0
|
||||
}
|
||||
|
||||
function getLocalRespawnDelay(unitName, spawn) {
|
||||
if (unitName == null || spawn == null || !isPerBaseDelayRow(spawn))
|
||||
return null
|
||||
let departedAt = this.wtoAirfieldDepartures?[unitName]?[spawn.id]
|
||||
if (departedAt == null)
|
||||
return null
|
||||
let delay = get_current_mission_info_cached()?.afterRespawnDelaySec ?? 0
|
||||
let elapsed = (require("dagor.time").get_time_msec() - departedAt) / 1000
|
||||
return max(0, delay - elapsed.tointeger())
|
||||
}
|
||||
|
||||
function getPerBaseRespawnDelays(respawnBasesList, unitName) {
|
||||
local baseDelays = {}
|
||||
if ((get_current_mission_info_cached()?.afterRespawnDelaySec ?? 0) <= 0)
|
||||
return baseDelays
|
||||
foreach (spawn in respawnBasesList)
|
||||
if (isPerBaseDelayRow(spawn))
|
||||
baseDelays[spawn.id] <- this.getLocalRespawnDelay(unitName, spawn) ?? get_slot_delay(unitName, spawn.id)
|
||||
return baseDelays
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
function onLocalAirfieldSpawn(event) {
|
||||
let { unitName, baseId } = event
|
||||
let departures = this.wtoAirfieldDepartures?[unitName] ?? {}
|
||||
departures[baseId] <- require("dagor.time").get_time_msec()
|
||||
this.wtoAirfieldDepartures[unitName] <- departures
|
||||
}
|
||||
|
||||
function onEventHudEventManagerReset(_p) {
|
||||
let { g_hud_event_manager } = require("%scripts/hud/hudEventManager.nut")
|
||||
g_hud_event_manager.subscribe("wtoLocalMpAirfieldSpawn", this.onLocalAirfieldSpawn, this)
|
||||
}
|
||||
|
||||
function onEventLoadingStateChange(_p) {
|
||||
if (!isInFlight()) {
|
||||
this.resetSelectedBase()
|
||||
this.wtoAirfieldDepartures.clear()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
let crewId = crew.idInCountry
|
||||
let syncRecvTime = getSpawnDelayTimesRecvTime()
|
||||
let prevState = this.lastRespawnBaseLockState
|
||||
@@ -0,0 +1,22 @@
|
||||
let respawnBaseId = this.curRespawnBase?.id ?? 0
|
||||
let syncRecvTime = getSpawnDelayTimesRecvTime()
|
||||
foreach (crew in crews) {
|
||||
let idInCountry = crew.idInCountry
|
||||
let cacheKey = $"{idInCountry}_{respawnBaseId}"
|
||||
let curSlotDelay = get_slot_delay_by_slot(idInCountry, respawnBaseId)
|
||||
local slotDelayChanged = false
|
||||
if (!(cacheKey in this.slotDelayDataCached)) {
|
||||
this.slotDelayDataCached[cacheKey] <- {
|
||||
slotDelay = curSlotDelay
|
||||
updateTime = curSlotDelay >= 0 ? syncRecvTime : 0
|
||||
}
|
||||
slotDelayChanged = curSlotDelay >= 0
|
||||
}
|
||||
else {
|
||||
let slotDelayData = this.slotDelayDataCached[cacheKey]
|
||||
if (slotDelayData.slotDelay != curSlotDelay) {
|
||||
slotDelayData.slotDelay = curSlotDelay
|
||||
slotDelayData.updateTime = syncRecvTime
|
||||
slotDelayChanged = true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
let slotDelay = this.getInterpolatedSlotDelay(crew.idInCountry, this.curRespawnBase.id)
|
||||
if (slotDelay > 0) {
|
||||
@@ -0,0 +1,19 @@
|
||||
// Feed LocalMP airfield delays into the stock slot countdown and base lock refresh.
|
||||
// The local matching service does not receive the flight server's per-slot delay snapshots.
|
||||
// The spawn button and base list need the host departure times to apply the same delay.
|
||||
{
|
||||
"id": "battle/use-local-airfield-respawn-delay",
|
||||
"title": "Use LocalMP airfield delays in the respawn screen",
|
||||
"features": ["K-Spawn score and respawns"],
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.58",
|
||||
"file": "scripts/respawn/respawn.nut",
|
||||
"edits": [
|
||||
{ "find": "find-spawn-check.nut", "replace": "replace-spawn-check.nut" },
|
||||
{ "find": "find-slot-delay.nut", "replace": "replace-slot-delay.nut" },
|
||||
{ "find": "find-base-refresh.nut", "replace": "replace-base-refresh.nut" }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
let crewId = crew.idInCountry
|
||||
let wtoHasDelays = "hasLocalRespawnDelays" in respawnBases && respawnBases.hasLocalRespawnDelays()
|
||||
let syncRecvTime = wtoHasDelays ? (get_time_msec() / 1000).tointeger() : getSpawnDelayTimesRecvTime()
|
||||
let prevState = this.lastRespawnBaseLockState
|
||||
@@ -0,0 +1,27 @@
|
||||
let respawnBaseId = this.curRespawnBase?.id ?? 0
|
||||
let syncRecvTime = getSpawnDelayTimesRecvTime()
|
||||
let wtoHasDelays = "hasLocalRespawnDelays" in respawnBases && respawnBases.hasLocalRespawnDelays()
|
||||
foreach (crew in crews) {
|
||||
let idInCountry = crew.idInCountry
|
||||
let cacheKey = $"{idInCountry}_{respawnBaseId}"
|
||||
let wtoDelay = wtoHasDelays
|
||||
? respawnBases.getLocalRespawnDelay(getCrewUnit(crew)?.name, this.curRespawnBase)
|
||||
: null
|
||||
let curSlotDelay = wtoDelay ?? get_slot_delay_by_slot(idInCountry, respawnBaseId)
|
||||
let slotRecvTime = wtoDelay == null ? syncRecvTime : get_time_msec()
|
||||
local slotDelayChanged = false
|
||||
if (!(cacheKey in this.slotDelayDataCached)) {
|
||||
this.slotDelayDataCached[cacheKey] <- {
|
||||
slotDelay = curSlotDelay
|
||||
updateTime = curSlotDelay >= 0 ? slotRecvTime : 0
|
||||
}
|
||||
slotDelayChanged = curSlotDelay >= 0
|
||||
}
|
||||
else {
|
||||
let slotDelayData = this.slotDelayDataCached[cacheKey]
|
||||
if (slotDelayData.slotDelay != curSlotDelay) {
|
||||
slotDelayData.slotDelay = curSlotDelay
|
||||
slotDelayData.updateTime = slotRecvTime
|
||||
slotDelayChanged = true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
let wtoDelay = "getLocalRespawnDelay" in respawnBases
|
||||
? respawnBases.getLocalRespawnDelay(unit.name, this.curRespawnBase)
|
||||
: null
|
||||
let slotDelay = wtoDelay ?? this.getInterpolatedSlotDelay(crew.idInCountry, this.curRespawnBase.id)
|
||||
if (slotDelay > 0) {
|
||||
@@ -0,0 +1,323 @@
|
||||
// Ground Arcade air events (fighter/attacker/bomber killstreaks) on a LocalMP host
|
||||
// (native/wto-net/src/local_mp_air_events.c).
|
||||
// Why the local server cannot do this alone: LocalMP initialization clears MissionSettings.useKillStreaks,
|
||||
// local AI kill attribution does not advance native killstreak counters, and BombingKillStreakEvent
|
||||
// broadcasts UnitRespawn via mpi::sendto without delivering it to the LocalMP host.
|
||||
// Without it: Ground Arcade air-event action bar slots stay unavailable or spawn without UnitRespawn.
|
||||
{
|
||||
"module": "local_mp_air_events",
|
||||
"features": [
|
||||
"K-Additional vehicles"
|
||||
],
|
||||
"requires": [
|
||||
"local_mp_core",
|
||||
"local_mp_kills"
|
||||
],
|
||||
"sites": {
|
||||
// MissionSettings gameModeName offset, captured where mission_settings_load reads "gameModeName".
|
||||
// 2.61.0.58: 0x126c4c8 (mode_name = 0x48).
|
||||
"mission_mode_name": {
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.58",
|
||||
"locate": {
|
||||
"method": "string_ref",
|
||||
"string": "gameModeName",
|
||||
"pattern": "48 8d 15 ?? ?? ?? ?? 4c 8d 44 24 50 4c 89 e9 e8 ?? ?? ?? ?? 48 8b 56 ??",
|
||||
"lea_at": 0,
|
||||
"captures": {
|
||||
"mode_name": {
|
||||
"offset": 23,
|
||||
"type": "u8"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// LocalMP mission preparation helper: clears MissionSettings.useKillStreaks at its tail.
|
||||
// 2.61.0.58: 0x12bf540.
|
||||
"prepare_local_mission": {
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.58",
|
||||
"locate": {
|
||||
"method": "signature",
|
||||
"pattern": "48 83 ec 48 48 8b 05 ?? ?? ?? ?? 80 b8 80 04 00 00 01 0f 85 ?? ?? ?? ?? 0f 1f 84 00 00 00 00 00 b9 10 00 00 00 e8 ?? ?? ?? ??"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// Tail store in prepare_local_mission that clears MissionSettings.useKillStreaks to 0.
|
||||
// 2.61.0.58: 0x12bf5d6 (use_kill_streaks = 0x7bc66b7).
|
||||
"prepare_local_mission_clear": {
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.58",
|
||||
"locate": {
|
||||
"method": "within",
|
||||
"in": "prepare_local_mission",
|
||||
"pattern": "c6 05 ?? ?? ?? ?? 00 48 83 c4 48 c3",
|
||||
"captures": {
|
||||
"use_kill_streaks": {
|
||||
"offset": 2,
|
||||
"type": "rel32",
|
||||
"end": 7
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// kill_streak_fighter_revert_es_event_handler: accesses gameplay killstreak rules, the killstreak
|
||||
// NameMap, and calls MPlayer::addKillStreakPoints.
|
||||
// 2.61.0.58: 0x33c9d0.
|
||||
"kill_streak_revert": {
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.58",
|
||||
"locate": {
|
||||
"method": "string_ref",
|
||||
"string": "kill_streak_fighter_revert_es_event_handler",
|
||||
"target": "function"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// Gameplay global, killstreak rules vector (data/count), rule tag id offset, and tag NameMap.
|
||||
// 2.61.0.58: 0x33ca72 (gameplay = 0x7bbe730, rule_count = 0x3818, rules = 0x3808, rule_tag = 0x3c, name_map = 0x7bbe670).
|
||||
"kill_streak_rules": {
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.58",
|
||||
"locate": {
|
||||
"method": "within",
|
||||
"in": "kill_streak_revert",
|
||||
"pattern": "48 8b 0d ?? ?? ?? ?? 48 63 81 ?? ?? ?? ?? 41 39 c5 73 ?? 48 8b 81 ?? ?? ?? ?? 42 8b 4c 30 ?? 3b 0d ?? ?? ?? ?? 73 ?? 48 8b 15 ?? ?? ?? ??",
|
||||
"captures": {
|
||||
"gameplay": {
|
||||
"offset": 3,
|
||||
"type": "rel32"
|
||||
},
|
||||
"rule_count": {
|
||||
"offset": 10,
|
||||
"type": "u32"
|
||||
},
|
||||
"rules": {
|
||||
"offset": 22,
|
||||
"type": "u32"
|
||||
},
|
||||
"rule_tag": {
|
||||
"offset": 30,
|
||||
"type": "u8"
|
||||
},
|
||||
"name_map": {
|
||||
"offset": 42,
|
||||
"type": "rel32"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// MPlayer::addKillStreakPoints(player, ruleIndex, points, relatedRule).
|
||||
// 2.61.0.58: 0x59e8a0 (called at 0x33cc47).
|
||||
"add_kill_streak_points": {
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.58",
|
||||
"locate": {
|
||||
"method": "signature",
|
||||
"pattern": "41 57 41 56 41 54 56 57 55 53 48 83 ec 20 48 89 ce 48 8b 05 ?? ?? ?? ?? 0f b6 ca 39 88 ?? ?? ?? ?? 0f 86 ?? ?? ?? ?? 48 8b 98 ?? ?? ?? ?? 89 c8 4c 8d 34 c0 41 c1 e6 04"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// MPlayer killstreak progress dag::Vector offset (data at +0x00, count at +0x10).
|
||||
// 2.61.0.58: 0x59e98e (progress = 0x788).
|
||||
"mplayer_streak_progress": {
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.58",
|
||||
"locate": {
|
||||
"method": "within",
|
||||
"in": "add_kill_streak_points",
|
||||
"pattern": "4c 8b 96 ?? ?? ?? ?? 89 d2 48 c1 e2 04 41 0f b6 04 12",
|
||||
"captures": {
|
||||
"progress": {
|
||||
"offset": 3,
|
||||
"type": "u32"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// Gameplay killstreak parser: airAiKillsMult and groundAiKillsMult offsets in a rule entry (stride 0x90).
|
||||
// 2.61.0.58: 0xeb097d (air_ai_mult = 0x28, ground_ai_mult = 0x2c).
|
||||
"kill_streak_ai_mults": {
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.58",
|
||||
"locate": {
|
||||
"method": "string_ref",
|
||||
"string": "airAiKillsMult",
|
||||
"pattern": "48 8d 15 ?? ?? ?? ?? 49 89 f8 e8 ?? ?? ?? ?? 89 46 ?? c7 44 24 30 01 00 00 00 4c 89 e1 48 8d 15 ?? ?? ?? ?? 49 89 f8 e8 ?? ?? ?? ?? 89 46 ??",
|
||||
"lea_at": 0,
|
||||
"captures": {
|
||||
"air_ai_mult": {
|
||||
"offset": 17,
|
||||
"type": "u8"
|
||||
},
|
||||
"ground_ai_mult": {
|
||||
"offset": 46,
|
||||
"type": "u8"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// BombingKillStreakEvent::initiateEvent: computes the initiator spawn position from gameplay.blk spawnPos.
|
||||
// 2.61.0.58: 0x1283c10.
|
||||
"air_event_initiate": {
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.58",
|
||||
"locate": {
|
||||
"method": "string_ref",
|
||||
"string": "%s: reject - event (%d) unavailable active %d, timeToStart %f",
|
||||
"target": "function"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// Battle-area center helper, room max rank global, and rule spawnPos table offsets in initiateEvent.
|
||||
// 2.61.0.58: 0x1283e05 (battle_center = 0x1284140, spawn_pos_count = 0x60, max_rank = 0x7bc666c, spawn_pos = 0x50, stride = 0x64).
|
||||
"air_event_spawn_table": {
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.58",
|
||||
"locate": {
|
||||
"method": "within",
|
||||
"in": "air_event_initiate",
|
||||
"pattern": "48 8d 4c 24 4c e8 ?? ?? ?? ?? 45 8b 47 ?? f3 44 0f 10 0d ?? ?? ?? ?? 45 0f 28 d1 45 0f 28 c1 4d 85 c0 4c 89 e0 0f 84 ?? ?? ?? ?? 8b 15 ?? ?? ?? ?? 49 8b 4f ?? 4d 6b c8 ??",
|
||||
"captures": {
|
||||
"battle_center": {
|
||||
"offset": 6,
|
||||
"type": "rel32"
|
||||
},
|
||||
"spawn_pos_count": {
|
||||
"offset": 13,
|
||||
"type": "u8"
|
||||
},
|
||||
"max_rank": {
|
||||
"offset": 45,
|
||||
"type": "rel32"
|
||||
},
|
||||
"spawn_pos": {
|
||||
"offset": 52,
|
||||
"type": "u8"
|
||||
},
|
||||
"spawn_pos_stride": {
|
||||
"offset": 56,
|
||||
"type": "u8"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// App terrain pointer offset and terrain height query call in initiateEvent.
|
||||
// 2.61.0.58: 0x1283f95 (app_terrain = 0x3d8, terrain_height = 0xf9bcd0).
|
||||
"air_event_terrain": {
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.58",
|
||||
"locate": {
|
||||
"method": "within",
|
||||
"in": "air_event_initiate",
|
||||
"pattern": "48 8b 05 ?? ?? ?? ?? 48 8b 88 ?? ?? ?? ?? 0f 57 c0 0f 11 44 24 20 e8 ?? ?? ?? ??",
|
||||
"captures": {
|
||||
"app_terrain": {
|
||||
"offset": 10,
|
||||
"type": "u32"
|
||||
},
|
||||
"terrain_height": {
|
||||
"offset": 23,
|
||||
"type": "rel32"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// BombingKillStreakEvent::switchPlayerUnit: switches the player to/from the event aircraft and calls sendUnitRespawn.
|
||||
// 2.61.0.58: 0x1287020.
|
||||
"air_event_switch_unit": {
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.58",
|
||||
"locate": {
|
||||
"method": "signature",
|
||||
"pattern": "41 57 41 56 41 54 56 57 55 53 48 81 ec f0 00 00 00 44 89 c5 48 89 d6 48 89 cf 48 8b 1a 44 8b 83 ?? ?? ?? ?? 8b 05 ?? ?? ?? ?? 48 8b 93 ?? ?? ?? ??"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// Matrix-to-quaternion orientation helper called by switchPlayerUnit when building the respawn pose.
|
||||
// 2.61.0.58: 0x1287309 (get_orientation = 0x280710).
|
||||
"air_event_orientation": {
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.58",
|
||||
"locate": {
|
||||
"method": "within",
|
||||
"in": "air_event_switch_unit",
|
||||
"pattern": "48 8d 8c 24 88 00 00 00 48 8d 54 24 40 e8 ?? ?? ?? ??",
|
||||
"captures": {
|
||||
"call": {
|
||||
"offset": 14,
|
||||
"type": "rel32"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// Unit::sendUnitRespawn: packs UnitRespawn (0xf030) and broadcasts it via mpi::sendto.
|
||||
// 2.61.0.58: 0xff13a0.
|
||||
"send_unit_respawn": {
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.58",
|
||||
"locate": {
|
||||
"method": "string_ref",
|
||||
"string": "sending unit respawn uid:%i name:%s ptr:%p at (%f, %f, %f)",
|
||||
"target": "function"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// mpi::sendto broadcast call at the end of Unit::sendUnitRespawn.
|
||||
// 2.61.0.58: 0xff17a1 (mpi_sendto = 0x30a0650).
|
||||
"send_unit_respawn_broadcast": {
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.58",
|
||||
"locate": {
|
||||
"method": "within",
|
||||
"in": "send_unit_respawn",
|
||||
"pattern": "48 8d 74 24 30 48 89 f1 e8 ?? ?? ?? ?? 48 89 f1 b2 ff e8 ?? ?? ?? ??",
|
||||
"captures": {
|
||||
"mpi_sendto": {
|
||||
"offset": 19,
|
||||
"type": "rel32"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
// In-battle award events (native/wto-net/src/local_mp_awards.c): the stock InBattleReward HUD event
|
||||
// and the facts sent to the local server for awards.
|
||||
// Without it: no reward banners and no battle awards in LocalMP battles.
|
||||
// and the facts sent to the local server for awards. Also reports confirmed airfield departures
|
||||
// for the LocalMP respawn UI, which otherwise expects the flight server to send cooldown records.
|
||||
{
|
||||
"module": "local_mp_awards",
|
||||
"features": [
|
||||
"L-Battle awards"
|
||||
"L-Battle awards",
|
||||
"K-Spawn score and respawns"
|
||||
],
|
||||
"requires": [
|
||||
"local_mp_core"
|
||||
|
||||
@@ -487,6 +487,20 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// Unit::onEvent: dispatches unit network messages (hits, respawns, state events) on a Unit.
|
||||
// Shared by local_mp_damage_notifications and local_mp_air_events.
|
||||
// 2.61.0.37: 0x103fbc0; 2.61.0.43: 0x1043fe0; 2.61.0.58: 0x1044650.
|
||||
"unit_on_event": {
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.37",
|
||||
"locate": {
|
||||
"method": "signature",
|
||||
"pattern": "41 57 41 56 41 55 41 54 56 57 55 53 48 81 ec c8 04 00 00 44 0f 29 bc 24 b0 04 00 00 44 0f 29 b4 24 a0 04 00 00 44 0f 29 ac 24 90 04 00 00 44 0f 29 a4 24 80 04 00 00 44 0f 29 9c 24 70 04 00 00 44 0f 29 94 24 60 04 00 00 44 0f 29 8c 24 50 04 00 00 44 0f 29 84 24 40 04 00 00 0f 29 bc 24 30 04 00 00 0f 29 b4 24 20 04 00 00 48 89 d7 49 89 cd 0f b7 42 20"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,21 +139,8 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
// Unit::onEvent: receives hit events for every unit on a LocalMP host and falls through into
|
||||
// enemy parts-list and hit-camera special-event delivery even when the attacker is an AI unit.
|
||||
// 2.61.0.37: 0x103fbc0; 2.61.0.43: 0x1043fe0.
|
||||
"unit_on_event": {
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.37",
|
||||
"locate": {
|
||||
"method": "signature",
|
||||
"pattern": "41 57 41 56 41 55 41 54 56 57 55 53 48 81 ec c8 04 00 00 44 0f 29 bc 24 b0 04 00 00 44 0f 29 b4 24 a0 04 00 00 44 0f 29 ac 24 90 04 00 00 44 0f 29 a4 24 80 04 00 00 44 0f 29 9c 24 70 04 00 00 44 0f 29 94 24 60 04 00 00 44 0f 29 8c 24 50 04 00 00 44 0f 29 84 24 40 04 00 00 0f 29 bc 24 30 04 00 00 0f 29 b4 24 20 04 00 00 48 89 d7 49 89 cd 0f b7 42 20"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// Hit event attacker Unit* offset loaded before comparing against g_hero in Unit::onEvent.
|
||||
// Hit event attacker Unit* offset loaded before comparing against g_hero in Unit::onEvent
|
||||
// (unit_on_event is resolved in local_mp_core).
|
||||
// 2.61.0.37: 0x104495d (offender=0xd0); 2.61.0.43: 0x1048d7d (offender=0xd0).
|
||||
"hit_event_offender": {
|
||||
"variants": [
|
||||
|
||||
@@ -117,7 +117,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
// UnitCrewSkills::initFromSave.
|
||||
// UnitCrewSkills::initFromSave, required by hook DLLs bundled in 0.1.2.
|
||||
// 2.61.0.37: 0x1032130
|
||||
"crew_skills_init": {
|
||||
"variants": [
|
||||
@@ -408,6 +408,7 @@
|
||||
},
|
||||
// A Unit method that starts by reading the unit crew skills.
|
||||
// 2.61.0.37: 0x485850 (push r15; push r14; push r12; ...)
|
||||
// Also required by the 0.1.2 hook DLLs.
|
||||
"unit_crew_skills": {
|
||||
"variants": [
|
||||
{
|
||||
|
||||
@@ -30,6 +30,7 @@ import {
|
||||
copyPlayerDecalCache,
|
||||
NETWORK_HOOK_LIBRARY,
|
||||
playerDecalCacheProblem,
|
||||
readPlayerDecalIndexFiles,
|
||||
readStockGameFiles,
|
||||
writeGameCopy,
|
||||
type GameCopyBuild,
|
||||
@@ -72,6 +73,7 @@ function main(): number {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const decalIndexFiles = decalCache === undefined ? undefined : readPlayerDecalIndexFiles(decalCache);
|
||||
const build = buildGameCopy({
|
||||
stock: readStockGameFiles(values.game),
|
||||
port: Number(values.port),
|
||||
@@ -79,6 +81,7 @@ function main(): number {
|
||||
networkHookLibrary: readFileSync(hookLibraryPath),
|
||||
multiVehiclePackIds: multiVehiclePackIds(values.data, (line) => console.log(line)),
|
||||
placeholderDecals: decalCache === undefined,
|
||||
...(decalIndexFiles ? { decalIndexFiles } : {}),
|
||||
});
|
||||
report(build, values.verbose);
|
||||
|
||||
|
||||
Reference in new issue
Block a user