@scm-js/core 0.13.3 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1436 -275
- package/dist/index.mjs +10162 -5273
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @scm-js/core 0.
|
|
2
|
+
* @scm-js/core 0.14.1 — StarCraft maps as the scmJS editor reads and writes them.
|
|
3
3
|
* Generated by `npm run build:core` in github.com/scm-js/scm-js from core/src/index.ts; the guide is docs/core.md.
|
|
4
4
|
*/
|
|
5
|
+
import { CarriedModule as PatcherPlugin, DataSetRace, ExeArchive as PackageExeArchive, GAME_ARCHIVES, GAME_FOLDERS, GAME_NETWORK_TBL_ENTRIES, Identity, MAX_RACE_NAME as RACE_NAME_MAX, MOD_MESSAGES, ModDescription, ModError as ModSourceError, ModFiles, ModMessage, PatcherError, RaceCandidates, SYSTEM_FILES, ZipMember, gameCopyFiles, hashLines, hashLinesAsWere, isCodeFile as isModCode, isExe, isMpq, isPluginFile, isSystemFile, isSystemLine, isZip, libraryName, modRoot, normalizeRaces, probeNames, programEnd, raceCandidates, readMod, readZip, renderMessage, sha256Hex as fileDigest } from '@scm-js/mod';
|
|
5
6
|
import { Archive, HashEntry, StoredMember } from 'mopaq';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -160,11 +161,15 @@ export interface LocationRecord {
|
|
|
160
161
|
/** Bit 0 low ground, 1 medium, 2 high, 3 low air, 4 medium air, 5 high air. */
|
|
161
162
|
elevationFlags: number;
|
|
162
163
|
}
|
|
164
|
+
/** Location index 63 (1-based 64) is the fixed "Anywhere" location. */
|
|
165
|
+
export declare const ANYWHERE_INDEX = 63;
|
|
163
166
|
/**
|
|
164
167
|
* How many location slots a file of this revision has. The game takes `MRGN` only at
|
|
165
168
|
* exactly this size: 64 slots in a StarCraft 1.00 file (`VER` below 63), 255 from 63 up.
|
|
166
169
|
*/
|
|
167
170
|
export declare function locationSlots(fileVersion: number): number;
|
|
171
|
+
/** A location is "unused" when it is degenerate and unnamed. */
|
|
172
|
+
export declare function isLocationUsed(l: LocationRecord): boolean;
|
|
168
173
|
export declare const PLAYER_SLOTS = 12;
|
|
169
174
|
/** Forces only cover the eight playable slots. */
|
|
170
175
|
export declare const FORCE_SLOTS = 8;
|
|
@@ -1016,6 +1021,8 @@ export interface WriteArchiveOptions {
|
|
|
1016
1021
|
encrypt?: boolean;
|
|
1017
1022
|
/** Write a (listfile) naming the members (default on). */
|
|
1018
1023
|
listfile?: boolean;
|
|
1024
|
+
/** Carry a member read from a form the writer cannot make (an ADPCM sound) as stored while unchanged (default on). */
|
|
1025
|
+
carryStored?: boolean;
|
|
1019
1026
|
}
|
|
1020
1027
|
/** The archive around a scenario's bytes as given — `readArchive` the other way; the editor's sector rule (zlib likes big sectors). */
|
|
1021
1028
|
export declare function writeArchiveBytes(chk: Uint8Array, options?: WriteArchiveOptions): Promise<Uint8Array>;
|
|
@@ -1031,6 +1038,49 @@ export interface WriteOptions {
|
|
|
1031
1038
|
}
|
|
1032
1039
|
/** Serialise the scenario to the bytes that belong in the target file. */
|
|
1033
1040
|
export declare function writeMapBytes(scenario: Scenario, options: WriteOptions): Promise<Uint8Array>;
|
|
1041
|
+
/** The file key of a member: the hash of its name after the last slash, as the game takes it (ASCII upper case). */
|
|
1042
|
+
export declare function fileKey(name: string, offset: number, size: number, adjusted: boolean): number;
|
|
1043
|
+
/**
|
|
1044
|
+
* The methods a member's sectors are compressed with, as the sector's method byte has them (0x01 Huffman, 0x02 zlib,
|
|
1045
|
+
* 0x08 PKWARE, 0x10 bzip2, 0x40 and 0x80 ADPCM), OR-ed together: 0x08 for an imploded member, 0 for one stored plain.
|
|
1046
|
+
* Null when the member's sector table does not read.
|
|
1047
|
+
*/
|
|
1048
|
+
export declare function storedMethods(m: StoredMember, name: string): number | null;
|
|
1049
|
+
/** zlib and bzip2: methods StarCraft 1.16.1 cannot read (it reads PKWARE, Huffman and ADPCM). */
|
|
1050
|
+
export declare const REMASTERED_ONLY_METHODS: number;
|
|
1051
|
+
/**
|
|
1052
|
+
* Whether a member is stored in a form the writer cannot make: a compressed sector that uses a method other than
|
|
1053
|
+
* PKWARE or zlib — StarEdit's ADPCM and Huffman for sounds, or bzip2. Written afresh, such a member comes out larger
|
|
1054
|
+
* (ADPCM is lossy) or in another method; carried as stored it stays as it was.
|
|
1055
|
+
*/
|
|
1056
|
+
export declare function storedInOtherForm(m: StoredMember, name: string): boolean;
|
|
1057
|
+
/**
|
|
1058
|
+
* The member as it would be stored at `offset`: the same bytes when its key does not depend on where it is, else its
|
|
1059
|
+
* sector table and sectors decrypted with the old key and encrypted with the new.
|
|
1060
|
+
*/
|
|
1061
|
+
export declare function relocate(m: StoredMember, name: string, offset: number): StoredMember;
|
|
1062
|
+
/**
|
|
1063
|
+
* Named members laid one after another from the archive's start, round the members with no name (which cannot be
|
|
1064
|
+
* re-keyed and stay where they are); a member that cannot be moved stays where it was too.
|
|
1065
|
+
*/
|
|
1066
|
+
export declare function packStored(named: {
|
|
1067
|
+
member: StoredMember;
|
|
1068
|
+
name: string;
|
|
1069
|
+
}[], pinned: readonly StoredMember[]): StoredMember[];
|
|
1070
|
+
/** A member's stored form, kept with the bytes it decodes to: what a save needs to carry it again. */
|
|
1071
|
+
export interface StoredForm {
|
|
1072
|
+
/** The member's name in the archive it came from (its key and its hash-table slot are the name's). */
|
|
1073
|
+
name: string;
|
|
1074
|
+
/** Its sectors' methods (`storedMethods`): a save for 1.16.1 does not carry one with zlib or bzip2 in it. */
|
|
1075
|
+
methods: number;
|
|
1076
|
+
member: StoredMember;
|
|
1077
|
+
/** The hash table of the archive it came from, which the slot belongs to; one array for every member of that archive. */
|
|
1078
|
+
hashTable: readonly HashEntry[];
|
|
1079
|
+
}
|
|
1080
|
+
/** Remember that `bytes` were read from `form`, so a save that is handed them unchanged can carry the member as stored. */
|
|
1081
|
+
export declare function keepStoredForm(bytes: Uint8Array, form: StoredForm): void;
|
|
1082
|
+
/** The stored form `bytes` were read from, while they are unchanged; null otherwise. */
|
|
1083
|
+
export declare function storedFormOf(bytes: Uint8Array): StoredForm | null;
|
|
1034
1084
|
export interface CreateScenarioOptions {
|
|
1035
1085
|
width: number;
|
|
1036
1086
|
height: number;
|
|
@@ -1148,6 +1198,8 @@ export declare function decodeFlingyDat(data: Uint8Array, fileName?: string): Fl
|
|
|
1148
1198
|
export declare function decodeSpritesDat(data: Uint8Array, fileName?: string): SpritesDat;
|
|
1149
1199
|
export declare function decodeImagesDat(data: Uint8Array, fileName?: string): ImagesDat;
|
|
1150
1200
|
export declare const MEGATILE_PX = 32;
|
|
1201
|
+
/** Bytes of one group in a `.cv5`: a table's length in groups is its size over this. */
|
|
1202
|
+
export declare const CV5_ENTRY_BYTES = 52;
|
|
1151
1203
|
export interface Cv5Group {
|
|
1152
1204
|
/** Doodad groups store 1 here; terrain groups store a group type. */
|
|
1153
1205
|
index: number;
|
|
@@ -1222,6 +1274,7 @@ export interface TilesetFiles {
|
|
|
1222
1274
|
vx4Extended?: boolean;
|
|
1223
1275
|
wpe: Uint8Array;
|
|
1224
1276
|
}
|
|
1277
|
+
export declare function decodeCv5(cv5: Uint8Array): Cv5Group[];
|
|
1225
1278
|
/** A .vx4ex file is 64 bytes per megatile where .vx4 is 32; the caller usually knows which. */
|
|
1226
1279
|
export declare function loadTileset(files: TilesetFiles): Tileset;
|
|
1227
1280
|
/**
|
|
@@ -1448,6 +1501,8 @@ export interface IsomEdit {
|
|
|
1448
1501
|
tiles: TileChange[];
|
|
1449
1502
|
/** Changes to `scenario.isom`, indexed by u16. */
|
|
1450
1503
|
isom: TileChange[];
|
|
1504
|
+
/** The tiles the brush would have changed and did not, because they are pinned (editor/pins.ts). */
|
|
1505
|
+
kept: number[];
|
|
1451
1506
|
}
|
|
1452
1507
|
/** True when the scenario carries an ISOM section the brush can work on. */
|
|
1453
1508
|
export declare function hasIsom(scn: Scenario | null): scn is Scenario & {
|
|
@@ -1456,11 +1511,13 @@ export declare function hasIsom(scn: Scenario | null): scn is Scenario & {
|
|
|
1456
1511
|
/**
|
|
1457
1512
|
* Paint `terrainType` (a CV5 index) with an `extent`-diamond brush centred on `d`.
|
|
1458
1513
|
* Mutates `scn.tiles` and `scn.isom`; returns what changed, or null when the terrain is
|
|
1459
|
-
* not one the tileset paints isometrically or `d` is not a diamond.
|
|
1514
|
+
* not one the tileset paints isometrically or `d` is not a diamond. Tiles marked in
|
|
1515
|
+
* `pinned` (a byte per tile) are left as they are: the lattice still changes under them,
|
|
1516
|
+
* so the ground around them is laid as if they had followed.
|
|
1460
1517
|
*/
|
|
1461
1518
|
export declare function paintIsom(scn: Scenario & {
|
|
1462
1519
|
isom: Uint16Array;
|
|
1463
|
-
}, tileset: Tileset, d: Diamond, terrainType: number, extent: number, random?: () => number): IsomEdit | null;
|
|
1520
|
+
}, tileset: Tileset, d: Diamond, terrainType: number, extent: number, random?: () => number, pinned?: Uint8Array | null): IsomEdit | null;
|
|
1464
1521
|
/**
|
|
1465
1522
|
* Paint `terrainType` (a CV5 index) over any set of diamonds in one stroke: each is set to
|
|
1466
1523
|
* the terrain, the neighbours they leave are re-picked as `paintIsom` re-picks the edge of
|
|
@@ -1471,7 +1528,7 @@ export declare function paintIsom(scn: Scenario & {
|
|
|
1471
1528
|
*/
|
|
1472
1529
|
export declare function paintIsomDiamonds(scn: Scenario & {
|
|
1473
1530
|
isom: Uint16Array;
|
|
1474
|
-
}, tileset: Tileset, diamonds: readonly Diamond[], terrainType: number, random?: () => number): IsomEdit | null;
|
|
1531
|
+
}, tileset: Tileset, diamonds: readonly Diamond[], terrainType: number, random?: () => number, pinned?: Uint8Array | null): IsomEdit | null;
|
|
1475
1532
|
export interface IsomCheck {
|
|
1476
1533
|
/** Rects that have tiles under them. */
|
|
1477
1534
|
rects: number;
|
|
@@ -1700,11 +1757,22 @@ export declare function summarizeTrigger(t: ReadonlyTrigger, names: TriggerNames
|
|
|
1700
1757
|
export declare function triggerComment(t: ReadonlyTrigger, names: TriggerNames): string | null;
|
|
1701
1758
|
/**
|
|
1702
1759
|
* A `TriggerNames` over the scenario. `intern` appends to the string table (marking it
|
|
1703
|
-
* dirty)
|
|
1704
|
-
*
|
|
1705
|
-
*
|
|
1760
|
+
* dirty) the moment it is called, and strings are never removed. So it is for printing, and
|
|
1761
|
+
* for a caller that means every string it interns to stay. Parsing text does not: the
|
|
1762
|
+
* parser interns as it reads, and a text with a mistake on a later line has by then added
|
|
1763
|
+
* the strings of the lines before it — `parseTriggerText` is the way to parse. An editor
|
|
1764
|
+
* that interns as the user types wants `draftTriggerNames` for the same reason.
|
|
1706
1765
|
*/
|
|
1707
1766
|
export declare function triggerNames(scn: Scenario): TriggerNames;
|
|
1767
|
+
/**
|
|
1768
|
+
* The strings a dialog's working copy has typed but the map does not hold yet. A draft's
|
|
1769
|
+
* index is negative — nothing a TRIG record decodes to — so a working copy can carry it in
|
|
1770
|
+
* the same field as a real one until `resolveDraftStrings` swaps it.
|
|
1771
|
+
*/
|
|
1772
|
+
export interface StringDrafts {
|
|
1773
|
+
byText: Map<string, number>;
|
|
1774
|
+
byIndex: Map<number, string>;
|
|
1775
|
+
}
|
|
1708
1776
|
export declare function readTriggers(scn: Scenario): TriggerRecord[];
|
|
1709
1777
|
export declare function readBriefing(scn: Scenario): TriggerRecord[];
|
|
1710
1778
|
/** Replace the trigger list. Marks TRIG dirty only when something differs. */
|
|
@@ -1747,13 +1815,19 @@ export declare function encodeTrg(triggers: readonly ReadonlyTrigger[]): Uint8Ar
|
|
|
1747
1815
|
/** Read a .trg; throws when the length is not a whole number of records. */
|
|
1748
1816
|
export declare function decodeTrg(bytes: Uint8Array): TriggerRecord[];
|
|
1749
1817
|
export declare function triggersToText(scn: Scenario, triggers: TriggerRecord[], briefing?: boolean): string;
|
|
1750
|
-
/**
|
|
1751
|
-
|
|
1818
|
+
/**
|
|
1819
|
+
* Parse TrigEdit text against the map's names; throws `TriggerTextError` with the line.
|
|
1820
|
+
* The strings the text mentions are added to the map only once all of it has parsed, so a
|
|
1821
|
+
* text with a mistake in it leaves the string table as it was. With `drafts` they are not
|
|
1822
|
+
* added at all: the ones the map lacks come back as drafts, for `resolveDraftStrings` to
|
|
1823
|
+
* add when the triggers are applied (Import Triggers reads the file before Import is pressed).
|
|
1824
|
+
*/
|
|
1825
|
+
export declare function triggersFromText(scn: Scenario, text: string, briefing?: boolean, drafts?: StringDrafts): TriggerRecord[];
|
|
1752
1826
|
export type TriggerFileFormat = "trg" | "txt";
|
|
1753
1827
|
/** The format a file name implies: `.trg` is binary, anything else text. */
|
|
1754
1828
|
export declare function triggerFormatOf(fileName: string): TriggerFileFormat;
|
|
1755
|
-
/** Read either kind of trigger file. */
|
|
1756
|
-
export declare function readTriggerFile(scn: Scenario, fileName: string, bytes: Uint8Array, briefing?: boolean): TriggerRecord[];
|
|
1829
|
+
/** Read either kind of trigger file. `drafts` as for `triggersFromText`; a `.trg` holds indices, not strings, and has none. */
|
|
1830
|
+
export declare function readTriggerFile(scn: Scenario, fileName: string, bytes: Uint8Array, briefing?: boolean, drafts?: StringDrafts): TriggerRecord[];
|
|
1757
1831
|
export declare function escapeStringText(text: string): string;
|
|
1758
1832
|
export declare function unescapeStringText(text: string): string;
|
|
1759
1833
|
/** The whole table as text; unset slots are skipped. */
|
|
@@ -2317,6 +2391,11 @@ export interface ResizeResult {
|
|
|
2317
2391
|
/** True when ISOM was reconstructed from the tiles; false when it is the flat fill's lattice. */
|
|
2318
2392
|
isomRebuilt: boolean;
|
|
2319
2393
|
}
|
|
2394
|
+
/** Tile offset of the old map inside the new one for an anchor; `dx` is even. */
|
|
2395
|
+
export declare function resizeOffset(oldW: number, oldH: number, newW: number, newH: number, anchor: number): {
|
|
2396
|
+
dx: number;
|
|
2397
|
+
dy: number;
|
|
2398
|
+
};
|
|
2320
2399
|
export declare function resizeScenario(scn: Scenario, options: ResizeOptions): ResizeResult;
|
|
2321
2400
|
export interface PlacementOptions {
|
|
2322
2401
|
/** Refuse to put a unit on top of another (ground units and buildings only). */
|
|
@@ -2365,6 +2444,759 @@ export declare function idealStarts(width: number, height: number, players: numb
|
|
|
2365
2444
|
* ones placed before it, so they never overlap each other.
|
|
2366
2445
|
*/
|
|
2367
2446
|
export declare function placeStartLocations(scn: Scenario, tileset: Tileset | null, tables: UnitsDat | null, options: StartPlacementOptions): StartPlacementResult;
|
|
2447
|
+
/** A copy's 4 × 4-pixel block means are within this much a channel of the source's, on average over the blocks. */
|
|
2448
|
+
export declare const BORROW_BLOCK = 2.5;
|
|
2449
|
+
/** …and its pixels within this much a channel, on average (the dither's own noise). */
|
|
2450
|
+
export declare const BORROW_PIXEL = 10;
|
|
2451
|
+
/**
|
|
2452
|
+
* Two 32-bit hashes of everything a table depends on — the groups, the megatile references, the
|
|
2453
|
+
* minitile pixels, the palette and the flags — so a stored table is found again for the same
|
|
2454
|
+
* files and never for others.
|
|
2455
|
+
*/
|
|
2456
|
+
export declare function tilesetHash(ts: Tileset): string;
|
|
2457
|
+
export interface Pictures {
|
|
2458
|
+
count: number;
|
|
2459
|
+
/** Per megatile the 64 sums of a 4 × 4 block's pixels, R G B: `blocks[m * 192 + block * 3 + channel]`. */
|
|
2460
|
+
blocks: Uint16Array;
|
|
2461
|
+
/** The mean of all its pixels and channels. */
|
|
2462
|
+
lum: Float32Array;
|
|
2463
|
+
/** Megatiles by `lum`, and their `lum` in that order: the search window. */
|
|
2464
|
+
byLum: Uint32Array;
|
|
2465
|
+
lumSorted: Float32Array;
|
|
2466
|
+
}
|
|
2467
|
+
export interface Slicing {
|
|
2468
|
+
/** Awaited between slices so the page can draw; a test passes nothing. */
|
|
2469
|
+
pause?(): Promise<void>;
|
|
2470
|
+
/** Told as the work goes: how far, of how far. */
|
|
2471
|
+
progress?(done: number, total: number): void;
|
|
2472
|
+
}
|
|
2473
|
+
/** A tileset's pictures summarised for the copy test, worked out once per tileset. */
|
|
2474
|
+
export declare function picturesOf(ts: Tileset, slicing?: Slicing): Promise<Pictures>;
|
|
2475
|
+
export interface Copy {
|
|
2476
|
+
/** The host megatile. */
|
|
2477
|
+
m: number;
|
|
2478
|
+
/** Its block distance and pixel distance from the source's picture. */
|
|
2479
|
+
block: number;
|
|
2480
|
+
pixel: number;
|
|
2481
|
+
}
|
|
2482
|
+
/**
|
|
2483
|
+
* Every host megatile within `block` / `pixel` of source megatile `m`, nearest first. The overall
|
|
2484
|
+
* mean and the 8 × 8 means are never further apart than the 4 × 4 means, so the window on `lum`
|
|
2485
|
+
* and the coarse test lose nothing.
|
|
2486
|
+
*/
|
|
2487
|
+
export declare function copiesOf(source: Tileset, sp: Pictures, m: number, host: Tileset, hp: Pictures, block?: number, pixel?: number): Copy[];
|
|
2488
|
+
/**
|
|
2489
|
+
* How a source tile's host tile relates to it: the same megatile flags (VF4) and group flag word
|
|
2490
|
+
* (`"identical"`), the same VF4 under another flag word (`"vf4"`), the picture only (`"picture"`),
|
|
2491
|
+
* the nearest picture where there is no copy (`"standIn"`), or what a plugin said (`"provided"`).
|
|
2492
|
+
*/
|
|
2493
|
+
export type BorrowKind = "identical" | "vf4" | "picture" | "standIn" | "provided";
|
|
2494
|
+
export interface BorrowTable {
|
|
2495
|
+
/** Source tile id → host tile ids showing its picture, all of one kind to the game, best first. */
|
|
2496
|
+
choices: Map<number, number[]>;
|
|
2497
|
+
/** How the choices relate to the source tile. */
|
|
2498
|
+
kinds: Map<number, BorrowKind>;
|
|
2499
|
+
/** Source megatile → host megatiles that are copies of it (stand-ins included): what the overwrite check reads. */
|
|
2500
|
+
copies: Map<number, number[]>;
|
|
2501
|
+
}
|
|
2502
|
+
/** Source tiles the brush can lay: tiles of typed groups (CV5 index ≥ 2) whose slot has a picture. */
|
|
2503
|
+
export declare function sourceTiles(source: Tileset): number[];
|
|
2504
|
+
/**
|
|
2505
|
+
* The table from `source` into `host`: for every source tile the brush can lay, the host tiles
|
|
2506
|
+
* showing a copy of its picture. Among them, a tile whose megatile's sixteen VF4 words and group
|
|
2507
|
+
* flag word equal the source's comes first; then the same VF4 words; then any. Only tiles of the
|
|
2508
|
+
* first one's kind to the game (`heal.ts#kindKey`) are kept, so choosing among them (which the
|
|
2509
|
+
* brush does, by how they join their neighbours) never changes how the ground walks or builds.
|
|
2510
|
+
* A source picture with no copy gets the nearest host picture within the stand-in bounds, else none.
|
|
2511
|
+
*/
|
|
2512
|
+
export declare function borrowTable(host: Tileset, source: Tileset, slicing?: Slicing): Promise<BorrowTable>;
|
|
2513
|
+
/**
|
|
2514
|
+
* A table a plugin or a mod's terrain file hands in: source tile → host tile, as the author meant them. Kind
|
|
2515
|
+
* `"provided"`, or `"standIn"` for the source tiles said to be only the nearest picture; the copies the check reads are
|
|
2516
|
+
* the pairs' megatiles.
|
|
2517
|
+
*/
|
|
2518
|
+
export declare function providedTable(host: Tileset, source: Tileset, pairs: Iterable<readonly [
|
|
2519
|
+
number,
|
|
2520
|
+
number
|
|
2521
|
+
]>, standIns?: Iterable<number>): BorrowTable;
|
|
2522
|
+
/** The table as numbers, for keeping in IndexedDB. */
|
|
2523
|
+
export declare function encodeBorrowTable(table: BorrowTable): Int32Array;
|
|
2524
|
+
export declare function decodeBorrowTable(data: ArrayLike<number>): BorrowTable | null;
|
|
2525
|
+
/** How many source tiles got each kind, and how many none. */
|
|
2526
|
+
export declare function tableCounts(source: Tileset, table: BorrowTable): Record<BorrowKind | "none", number>;
|
|
2527
|
+
/**
|
|
2528
|
+
* A terrain id at or above this names a borrowed terrain: `BORROWED_TERRAIN + (source ERA << 8)
|
|
2529
|
+
* + CV5 index`. Like the pair ids (`palette.ts#PAIR_TERRAIN`) it is the editor's own and never
|
|
2530
|
+
* written to a map.
|
|
2531
|
+
*/
|
|
2532
|
+
export declare const BORROWED_TERRAIN = 262144;
|
|
2533
|
+
export declare const borrowedTerrainId: (sourceEra: number, index: number) => number;
|
|
2534
|
+
export declare const isBorrowedTerrain: (id: number) => boolean;
|
|
2535
|
+
export declare const borrowedParts: (id: number) => {
|
|
2536
|
+
sourceEra: number;
|
|
2537
|
+
index: number;
|
|
2538
|
+
};
|
|
2539
|
+
/**
|
|
2540
|
+
* The borrowed brush taking ground back from a source: the diamonds it paints stop being borrowed, and their cells go
|
|
2541
|
+
* back to the tile they had before (`BorrowStroke.takeBack`). Index 0xFF, which no tileset's terrain uses.
|
|
2542
|
+
*/
|
|
2543
|
+
export declare const TAKE_BACK = 255;
|
|
2544
|
+
export declare const takeBackId: (sourceEra: number) => number;
|
|
2545
|
+
export declare const isTakeBack: (id: number) => boolean;
|
|
2546
|
+
export interface BorrowedTerrain {
|
|
2547
|
+
/** `borrowedTerrainId(sourceEra, index)`. */
|
|
2548
|
+
id: number;
|
|
2549
|
+
sourceEra: number;
|
|
2550
|
+
/** The CV5 index of the terrain in the source tileset (what the isometric brush paints there). */
|
|
2551
|
+
index: number;
|
|
2552
|
+
/** The source palette's name (English; shown through `translate`). */
|
|
2553
|
+
name: string;
|
|
2554
|
+
/** Tiles of the terrain and of the ground it is laid onto that have no copy and lay a stand-in. */
|
|
2555
|
+
standIns: number;
|
|
2556
|
+
/** A host tile showing the terrain, for a swatch. */
|
|
2557
|
+
tile: number;
|
|
2558
|
+
}
|
|
2559
|
+
/**
|
|
2560
|
+
* The ground a borrowed stroke meets where nothing borrowed was painted: the terrain a new map
|
|
2561
|
+
* of the source tileset is filled with (StarEdit's), so a first stroke lays what it would lay on
|
|
2562
|
+
* a fresh map of that tileset.
|
|
2563
|
+
*/
|
|
2564
|
+
export declare const borrowBase: (sourceEra: number) => number;
|
|
2565
|
+
/**
|
|
2566
|
+
* The source's terrains the host can lay whole: a terrain is offered when every tile of its own
|
|
2567
|
+
* groups, and of every type the brush steps through between it and the source's base ground
|
|
2568
|
+
* (the edge sets and the terrains between, `terrainTypeMap`'s path), has a host tile, stand-ins
|
|
2569
|
+
* being at most `STAND_IN_SHARE` of a type's tiles. A terrain the host already types as its own
|
|
2570
|
+
* ground (every tile with a copy in a typed group: a Jungle's Dirt in a Badlands) is left out: the
|
|
2571
|
+
* game's own brush lays it. Nothing for the host's own tileset. In the source palette's order.
|
|
2572
|
+
*/
|
|
2573
|
+
export declare function borrowableTerrains(host: Tileset, hostEra: number, source: Tileset, sourceEra: number, table: BorrowTable): BorrowedTerrain[];
|
|
2574
|
+
/** How transition cells count when the lattice is read: as neither terrain, or as the ground. */
|
|
2575
|
+
export type BorderMode = "neutral" | "asY";
|
|
2576
|
+
export declare const BORDER_MODES: readonly BorderMode[];
|
|
2577
|
+
/** One stand-in pair: a tileset, its ERA numbering, the ground (Y) and patch (X) terrains' CV5 index and the edge set's. */
|
|
2578
|
+
export interface StandIn {
|
|
2579
|
+
ts: Tileset;
|
|
2580
|
+
era: number;
|
|
2581
|
+
y: number;
|
|
2582
|
+
x: number;
|
|
2583
|
+
set: number;
|
|
2584
|
+
}
|
|
2585
|
+
/** The three stand-ins: X and Y at one height, X higher, X lower. */
|
|
2586
|
+
export interface StandIns {
|
|
2587
|
+
flat: StandIn;
|
|
2588
|
+
up: StandIn;
|
|
2589
|
+
down: StandIn;
|
|
2590
|
+
}
|
|
2591
|
+
/**
|
|
2592
|
+
* The game's Badlands as the stand-in: Grass on Dirt (a flat/flat set), High Dirt on Dirt and Dirt on High Dirt (the
|
|
2593
|
+
* cliff set). Indices are the game's Badlands CV5 terrain types, named in `data/isomTables.ts`.
|
|
2594
|
+
*/
|
|
2595
|
+
export declare const BADLANDS_STANDIN: {
|
|
2596
|
+
readonly era: 0;
|
|
2597
|
+
readonly dirt: 2;
|
|
2598
|
+
readonly highDirt: 3;
|
|
2599
|
+
readonly grass: 6;
|
|
2600
|
+
readonly grassDirt: 20;
|
|
2601
|
+
readonly dirtHighDirt: 34;
|
|
2602
|
+
};
|
|
2603
|
+
export declare function badlandsStandIns(ts: Tileset): StandIns;
|
|
2604
|
+
export interface Flats {
|
|
2605
|
+
flatGroup: Map<number, number>;
|
|
2606
|
+
softTo: Map<number, number>;
|
|
2607
|
+
}
|
|
2608
|
+
/** A tileset's flat terrains: index → first even group, and soft link → terrain index. */
|
|
2609
|
+
export declare function flatTerrainsOf(ts: Tileset, era: number): Flats;
|
|
2610
|
+
/** A rect's pattern: per side `A` (the ground's soft link), `B` (the patch's), `h<n>` a hard link, `s<n>` another soft link. */
|
|
2611
|
+
export declare function patternKey(e: Cv5Group["edges"], softTo: Map<number, number>, ground: number, patch: number): string;
|
|
2612
|
+
/**
|
|
2613
|
+
* Which diamonds are X: the diamond on the top-left corner of rect (dx, dy) — tile corner (2dx, dy) — is X when the
|
|
2614
|
+
* cells around its centre lean X. The 2 × 2 cells at the centre count double, the 4 × 2 box around once; transition
|
|
2615
|
+
* cells count as `mode` says.
|
|
2616
|
+
*/
|
|
2617
|
+
export declare function diamondsOf(cls: Uint8Array, w: number, h: number, mode: BorderMode): Diamond[];
|
|
2618
|
+
interface Window$1 {
|
|
2619
|
+
x0: number;
|
|
2620
|
+
y0: number;
|
|
2621
|
+
w: number;
|
|
2622
|
+
h: number;
|
|
2623
|
+
}
|
|
2624
|
+
/** One border cell as the stand-in lays it: its shape (`pattern|L` or `|R`) and whether it leans to the patch. */
|
|
2625
|
+
export interface BorderShape {
|
|
2626
|
+
shape: string;
|
|
2627
|
+
leansX: boolean;
|
|
2628
|
+
}
|
|
2629
|
+
/** What the stand-in lays over a window: per cell its border shape (null where none) and whether it is the patch's ground. */
|
|
2630
|
+
export interface StandInLaid {
|
|
2631
|
+
shapes: (BorderShape | null)[];
|
|
2632
|
+
inner: Uint8Array;
|
|
2633
|
+
}
|
|
2634
|
+
/**
|
|
2635
|
+
* Lay the X `diamonds` (map lattice coordinates) with the stand-in's X on its Y over `win`, and answer, per cell of the
|
|
2636
|
+
* window, the shape the stand-in gives it (null where it lays no edge tile of its set) and whether it lays the patch's
|
|
2637
|
+
* own ground there (the brush may widen a patch: a cliff keeps a margin).
|
|
2638
|
+
*/
|
|
2639
|
+
export declare function standInShapes(si: StandIn, win: Window$1, diamonds: Iterable<Diamond>): StandInLaid;
|
|
2640
|
+
/** A pair's key: the source's ERA, the source terrain (X), the host terrain (Y). */
|
|
2641
|
+
export declare const pairKey: (sourceEra: number, x: number, y: number) => string;
|
|
2642
|
+
export declare function pairOf(key: string): {
|
|
2643
|
+
sourceEra: number;
|
|
2644
|
+
x: number;
|
|
2645
|
+
y: number;
|
|
2646
|
+
};
|
|
2647
|
+
/** Counts per pair: maps it was seen on, and per reading (`BORDER_MODES`) shape → tile → times laid. */
|
|
2648
|
+
export interface BorderEvidence {
|
|
2649
|
+
pairs: Map<string, {
|
|
2650
|
+
maps: number;
|
|
2651
|
+
modes: Map<string, Map<number, number>>[];
|
|
2652
|
+
}>;
|
|
2653
|
+
}
|
|
2654
|
+
export declare const emptyBorderEvidence: () => BorderEvidence;
|
|
2655
|
+
/** What telling cells apart needs for one host and one source: the host, the source, its borrow table. */
|
|
2656
|
+
export interface BorderSourceCtx {
|
|
2657
|
+
host: Tileset;
|
|
2658
|
+
source: Tileset;
|
|
2659
|
+
sourceEra: number;
|
|
2660
|
+
table: BorrowTable;
|
|
2661
|
+
}
|
|
2662
|
+
/**
|
|
2663
|
+
* What telling cells apart needs for one host and every source whose borrow table is known: which host megatiles are
|
|
2664
|
+
* copies of a source's flat terrain (X, as `sourceEra << 10 | terrain index`), and which are copies of any source
|
|
2665
|
+
* picture at all (never a transition piece). Built once per learn or per stroke (`borderClasses`).
|
|
2666
|
+
*/
|
|
2667
|
+
export interface BorderClasses {
|
|
2668
|
+
host: Tileset;
|
|
2669
|
+
ctxs: readonly BorderSourceCtx[];
|
|
2670
|
+
xOf: Map<number, number>;
|
|
2671
|
+
anyCopy: Set<number>;
|
|
2672
|
+
/** Per packed X, its commonest megatile height on the host (filled when asked). */
|
|
2673
|
+
heights: Map<number, number>;
|
|
2674
|
+
}
|
|
2675
|
+
export declare function borderClasses(host: Tileset, ctxs: readonly BorderSourceCtx[]): BorderClasses;
|
|
2676
|
+
/** A cell's host terrain as Y: a typed flat terrain's index (by its picture), else -1. */
|
|
2677
|
+
export declare function hostTerrainOf(host: Tileset, tile: number): number;
|
|
2678
|
+
/** A host tile's kind for borders: an X (packed source terrain), a Y (host terrain index), a transition piece, or nothing. */
|
|
2679
|
+
export declare function cellKind(c: BorderClasses, tile: number): {
|
|
2680
|
+
x: number;
|
|
2681
|
+
y: number;
|
|
2682
|
+
t: boolean;
|
|
2683
|
+
};
|
|
2684
|
+
/** The stand-in a pair is laid with: by the heights of the host's copies of X and of its Y ground. */
|
|
2685
|
+
export declare function pairStandIn(sis: StandIns, c: BorderClasses, sourceEra: number, x: number, y: number): StandIn;
|
|
2686
|
+
/**
|
|
2687
|
+
* Count one map's borders into `into`: for each pair a transition cell sits between (a transition tile with exactly one
|
|
2688
|
+
* source flat terrain and one host flat terrain next to it, else within two cells), the lattice read in each mode over the
|
|
2689
|
+
* window around its transition cells, and each transition cell near both terrains counted for its shape.
|
|
2690
|
+
*/
|
|
2691
|
+
export declare function gatherBorderEvidence(into: BorderEvidence, tiles: ArrayLike<number>, w: number, h: number, c: BorderClasses, sis: StandIns): void;
|
|
2692
|
+
/** `from` added into `into`. */
|
|
2693
|
+
export declare function mergeBorderEvidence(into: BorderEvidence, from: BorderEvidence): BorderEvidence;
|
|
2694
|
+
/** The evidence as plain data (JSON), for IndexedDB. */
|
|
2695
|
+
export declare function encodeBorderEvidence(e: BorderEvidence): string;
|
|
2696
|
+
export declare function decodeBorderEvidence(text: unknown): BorderEvidence | null;
|
|
2697
|
+
/** A pair's table: the reading it uses, and per shape the tiles laid there, most laid first, with the times. */
|
|
2698
|
+
export interface BorderPairTable {
|
|
2699
|
+
key: string;
|
|
2700
|
+
x: number;
|
|
2701
|
+
y: number;
|
|
2702
|
+
sourceEra: number;
|
|
2703
|
+
mode: BorderMode;
|
|
2704
|
+
shapes: Map<string, [
|
|
2705
|
+
tile: number,
|
|
2706
|
+
laid: number
|
|
2707
|
+
][]>;
|
|
2708
|
+
/** Where it came from: `"maps"`, a plugin's id, or `@dataset:<id>`. */
|
|
2709
|
+
from: string;
|
|
2710
|
+
}
|
|
2711
|
+
/**
|
|
2712
|
+
* The tables the evidence gives: per pair, the reading whose tiles keep to one shape the most (a tile laid in two
|
|
2713
|
+
* shapes is a misreading of one of them). A pair seen on fewer than `minMaps` maps is left out.
|
|
2714
|
+
*/
|
|
2715
|
+
export declare function cutBorderTables(e: BorderEvidence, minMaps?: number): BorderPairTable[];
|
|
2716
|
+
/**
|
|
2717
|
+
* Further candidates from the sheet: the untyped tiles, no copy of the source's pictures, in groups within `reach` of a
|
|
2718
|
+
* group the table names — the rest of a drawn set the maps do not show whole. Doodad groups left out.
|
|
2719
|
+
*/
|
|
2720
|
+
export declare function sheetPool(c: BorderClasses, table: BorderPairTable, reach?: number): number[];
|
|
2721
|
+
/**
|
|
2722
|
+
* What a borrowed stroke needs to draw borders for one host and one source: the tables by pair (`pairKey`), the
|
|
2723
|
+
* stand-ins, the classes the tables were read with (for a pair's stand-in and the sheet's pool) and the pools, cut when
|
|
2724
|
+
* first asked (`poolOf`).
|
|
2725
|
+
*/
|
|
2726
|
+
export interface BorderSetup {
|
|
2727
|
+
tables: ReadonlyMap<string, BorderPairTable>;
|
|
2728
|
+
standIns: StandIns;
|
|
2729
|
+
classes: BorderClasses;
|
|
2730
|
+
pools: Map<BorderPairTable, number[]>;
|
|
2731
|
+
}
|
|
2732
|
+
export declare function poolOf(setup: BorderSetup, table: BorderPairTable): number[];
|
|
2733
|
+
export type Size = Pick<Scenario, "width" | "height">;
|
|
2734
|
+
/** The member holding the lattice borrowed from tileset `sourceEra` (`scmjs\borrowed-install.bin`). */
|
|
2735
|
+
export declare const borrowMember: (sourceEra: number) => string;
|
|
2736
|
+
/** Every borrowed-lattice member, by the source's ERA. */
|
|
2737
|
+
export declare const BORROW_MEMBERS: readonly string[];
|
|
2738
|
+
/** The lattice of the source's base ground for a map of this size. */
|
|
2739
|
+
export declare function baseLattice(size: Size, sourceEra: number): Uint16Array;
|
|
2740
|
+
/** The member for a lattice: the diamonds that are not the base ground. Null when all of them are. */
|
|
2741
|
+
export declare function encodeBorrowLattice(size: Size, sourceEra: number, isom: Uint16Array): Uint8Array | null;
|
|
2742
|
+
/** The diamonds a member holds for a map of this size and source, or null when it is not ours or for another size. */
|
|
2743
|
+
export declare function decodeBorrowLattice(member: Uint8Array | null | undefined, size: Size, sourceEra: number): [
|
|
2744
|
+
number,
|
|
2745
|
+
number
|
|
2746
|
+
][] | null;
|
|
2747
|
+
/** The whole lattice a member stands for: the base ground with its diamonds set. */
|
|
2748
|
+
export declare function latticeOf(member: Uint8Array | null | undefined, size: Size, sourceEra: number): Uint16Array;
|
|
2749
|
+
/** The member after a resize that moved the map's old top-left tile to (dx, dy). Null when nothing is left, or `dx` is odd (a lattice moves by whole rects, two tiles). */
|
|
2750
|
+
export declare function resizeBorrowMember(member: Uint8Array | null, from: Size, to: Size, sourceEra: number, dx: number, dy: number): Uint8Array | null;
|
|
2751
|
+
export interface BorrowContext {
|
|
2752
|
+
host: Tileset;
|
|
2753
|
+
source: Tileset;
|
|
2754
|
+
sourceEra: number;
|
|
2755
|
+
table: BorrowTable;
|
|
2756
|
+
}
|
|
2757
|
+
export interface BorrowStrokeResult {
|
|
2758
|
+
/** The member as the stroke left it (null: all base ground), and as it was. */
|
|
2759
|
+
before: Uint8Array | null;
|
|
2760
|
+
after: Uint8Array | null;
|
|
2761
|
+
/** The border record (`borderRecord.ts`) as it was and as the stroke left it. */
|
|
2762
|
+
recordBefore: Uint8Array | null;
|
|
2763
|
+
recordAfter: Uint8Array | null;
|
|
2764
|
+
/** Changes made when the stroke finished (the drawn borders), for the caller to apply and keep with the stroke's. */
|
|
2765
|
+
changes: TileChange[];
|
|
2766
|
+
/** Cells the brush would have written and did not, because they are pinned. */
|
|
2767
|
+
kept: number[];
|
|
2768
|
+
/** Cells whose source tile has no host tile at all: left as they were. */
|
|
2769
|
+
untranslated: number;
|
|
2770
|
+
/** Cells laid with a stand-in (the nearest picture where there is no copy). */
|
|
2771
|
+
standIns: number;
|
|
2772
|
+
/** Borrowed diamonds put back to the base ground before the stroke because other tools had written over their tiles. */
|
|
2773
|
+
reset: number;
|
|
2774
|
+
/** Joins between the stroke's cells and the map's own ground that the Seam Overlay draws. */
|
|
2775
|
+
seams: number;
|
|
2776
|
+
/** The cells the stroke reached (its settle writes these and a margin); null when it reached none. */
|
|
2777
|
+
box: {
|
|
2778
|
+
x0: number;
|
|
2779
|
+
y0: number;
|
|
2780
|
+
x1: number;
|
|
2781
|
+
y1: number;
|
|
2782
|
+
} | null;
|
|
2783
|
+
/** Drawn borders, when the stroke laid them: border cells laid with a drawn tile, left as the hard edge, and drawn tiles that walk unlike both sides (`unlike`). */
|
|
2784
|
+
borders: {
|
|
2785
|
+
cells: number;
|
|
2786
|
+
drawn: number;
|
|
2787
|
+
hard: number;
|
|
2788
|
+
kept: number;
|
|
2789
|
+
unlike: number;
|
|
2790
|
+
ms: number;
|
|
2791
|
+
} | null;
|
|
2792
|
+
}
|
|
2793
|
+
/**
|
|
2794
|
+
* One stroke of the borrowed brush on a map: built from the member as the stroke starts, fed
|
|
2795
|
+
* diamonds as the pointer moves (`paint`, which answers the changes to apply to the map, live),
|
|
2796
|
+
* and finished once (`finish`, the member to store and the counts for the status line).
|
|
2797
|
+
*
|
|
2798
|
+
* With a border setup (`BorderSetup`: the drawn-border tables for this tileset and source),
|
|
2799
|
+
* `finish` lays the patch's border where it meets the tileset's own ground (`borderPass.ts`):
|
|
2800
|
+
* the map as it was before any borrowed stroke is rebuilt from the record (`borderRecord.ts`),
|
|
2801
|
+
* the interior laid as the source's brush lays it, every border cell whose pair has a table
|
|
2802
|
+
* handed to the border pass, and only the difference written. Without one, the stroke is what
|
|
2803
|
+
* it always was, and still keeps the record, so ground can be taken back (`takeBack`).
|
|
2804
|
+
*/
|
|
2805
|
+
export declare class BorrowStroke {
|
|
2806
|
+
private readonly shadow;
|
|
2807
|
+
private readonly touched;
|
|
2808
|
+
private readonly keptAt;
|
|
2809
|
+
private untranslated;
|
|
2810
|
+
private standIns;
|
|
2811
|
+
readonly reset: number;
|
|
2812
|
+
readonly scn: Scenario;
|
|
2813
|
+
readonly ctx: BorrowContext;
|
|
2814
|
+
readonly before: Uint8Array | null;
|
|
2815
|
+
private readonly pinned;
|
|
2816
|
+
readonly recordBefore: Uint8Array | null;
|
|
2817
|
+
private readonly rec;
|
|
2818
|
+
/** Cells this stroke changed that the record does not hold yet: the tile they had. */
|
|
2819
|
+
private readonly firstBefore;
|
|
2820
|
+
private readonly borders;
|
|
2821
|
+
/** The cells the stroke reached, for the finishing pass. */
|
|
2822
|
+
private box;
|
|
2823
|
+
constructor(scn: Scenario, ctx: BorrowContext, before: Uint8Array | null, pinned?: Uint8Array | null, opts?: {
|
|
2824
|
+
record?: Uint8Array | null;
|
|
2825
|
+
borders?: BorderSetup | null;
|
|
2826
|
+
});
|
|
2827
|
+
/**
|
|
2828
|
+
* Whether a diamond is the patch a border runs around, and its terrain: a diamond the brush painted (the record), or
|
|
2829
|
+
* one holding a terrain of the source other than its base ground (a map whose record an older editor did not keep).
|
|
2830
|
+
* An edge value the brush laid around a patch is not the patch. `NOT_PATCH`, else the terrain's CV5 index, or
|
|
2831
|
+
* `PATCH_EDGE` for a painted diamond that is an edge now (between two borrowed terrains).
|
|
2832
|
+
*/
|
|
2833
|
+
private inPatch;
|
|
2834
|
+
/**
|
|
2835
|
+
* Put back to the base ground every borrowed diamond whose rect's tiles are no longer copies of
|
|
2836
|
+
* what the lattice lays there (written over by another tool), and lay the shadow again there.
|
|
2837
|
+
* Doodads' cells are judged by the ground under them. With drawn borders, a rect that touches
|
|
2838
|
+
* the tileset's own ground holds border tiles, not copies, and is left to the border pass.
|
|
2839
|
+
*/
|
|
2840
|
+
private checkAgainstMap;
|
|
2841
|
+
private grow;
|
|
2842
|
+
private growDiamond;
|
|
2843
|
+
/** The map tile a cell had before any borrowed stroke. */
|
|
2844
|
+
private hostBefore;
|
|
2845
|
+
/**
|
|
2846
|
+
* Paint the source terrain `index` (its CV5 index) on `diamonds` and answer the changes to the
|
|
2847
|
+
* map: the cells whose source tile changed, as host tiles. Null when the source cannot paint it.
|
|
2848
|
+
*/
|
|
2849
|
+
paint(diamonds: readonly Diamond[], index: number, random?: () => number): TileChange[] | null;
|
|
2850
|
+
/**
|
|
2851
|
+
* Take ground back: the diamonds go back to the source's base ground and stop being borrowed, and every cell whose
|
|
2852
|
+
* rect is no longer borrowed gets the tile it had before the borrowed brush wrote it. The border around what is
|
|
2853
|
+
* left is laid again when the stroke finishes.
|
|
2854
|
+
*/
|
|
2855
|
+
takeBack(diamonds: readonly Diamond[], random?: () => number): TileChange[];
|
|
2856
|
+
/** The chosen tiles as changes to the map, noting what they were for the record. */
|
|
2857
|
+
private write;
|
|
2858
|
+
/** The choice that leaves the least step across its four joins. */
|
|
2859
|
+
private bestJoin;
|
|
2860
|
+
/**
|
|
2861
|
+
* Lay the border of the borrowed ground over the stroke's box (and a margin): the map before any borrowed stroke
|
|
2862
|
+
* rebuilt from the record, the stand-in's reading of where the border runs and in which shape, the interior from
|
|
2863
|
+
* the shadow, each border cell from its pair's table (`layBorder`), and the cells the stand-in leaves outside back
|
|
2864
|
+
* to their host tile. Answers the changes against the map as it stands.
|
|
2865
|
+
*/
|
|
2866
|
+
private settle;
|
|
2867
|
+
/**
|
|
2868
|
+
* The cells that are outside the patch and outside every border cell the stand-in names, yet do not hold the tile
|
|
2869
|
+
* they had before any borrowed stroke: what a stroke with drawn borders should never leave. Over the whole map, or
|
|
2870
|
+
* the box a stroke settled (`BorrowStrokeResult.box`). For tests, on a stroke made and not painted.
|
|
2871
|
+
*/
|
|
2872
|
+
strays(box?: {
|
|
2873
|
+
x0: number;
|
|
2874
|
+
y0: number;
|
|
2875
|
+
x1: number;
|
|
2876
|
+
y1: number;
|
|
2877
|
+
}): number[];
|
|
2878
|
+
/**
|
|
2879
|
+
* The member as the stroke left it, the border record, the changes the finishing pass made (drawn borders) and what
|
|
2880
|
+
* the status line says. The caller applies `changes` to the map before committing.
|
|
2881
|
+
*/
|
|
2882
|
+
finish(): BorrowStrokeResult;
|
|
2883
|
+
}
|
|
2884
|
+
/**
|
|
2885
|
+
* A byte per tile, 1 where the borrowed lattice is not the base ground (either diamond of the tile's rect), or where a
|
|
2886
|
+
* diamond of `base` (the diamonds the brush painted, `borderRecord.ts`) is.
|
|
2887
|
+
*/
|
|
2888
|
+
export declare function borrowedCells(size: Size, sourceEra: number, isom: Uint16Array, base?: {
|
|
2889
|
+
has(d: number): boolean;
|
|
2890
|
+
}): Uint8Array;
|
|
2891
|
+
/** A pair (tile, piece) needs this many whole 4 × 4 pixel blocks of the piece kept at the same place. */
|
|
2892
|
+
export declare const KEPT_BLOCKS = 2;
|
|
2893
|
+
/** The gate: this share of the drawn pieces' minitiles must walk as the source piece and stand as high as the copy raises it. */
|
|
2894
|
+
export declare const GATE_FLAGS = 0.99;
|
|
2895
|
+
/** A flat copy (`palette.ts#TerrainCopy`): the copy's even group, the typed terrain it copies and that terrain's group. */
|
|
2896
|
+
export interface CopySource {
|
|
2897
|
+
group: number;
|
|
2898
|
+
source: number;
|
|
2899
|
+
sourceGroup: number;
|
|
2900
|
+
}
|
|
2901
|
+
export type CopyStatus = "complete" | "incomplete" | "rejected";
|
|
2902
|
+
/** One block of a tileset standing for an edge set of one of its terrains, at the copy's height. JSON-able. */
|
|
2903
|
+
export interface CopyBlock {
|
|
2904
|
+
/** A key that survives the tileset's groups moving: two hashes of the block's tiles' pictures (`blockKey`). */
|
|
2905
|
+
key: string;
|
|
2906
|
+
/** The copied terrain S (CV5 index), the copy S′'s even group and its height (VF4: 0 low, 1 mid, 2 high). */
|
|
2907
|
+
source: number;
|
|
2908
|
+
flat: number;
|
|
2909
|
+
height: number;
|
|
2910
|
+
/** How much higher the copy stands than S. */
|
|
2911
|
+
raise: number;
|
|
2912
|
+
/** The edge set E (CV5 index) and its other terrain O. */
|
|
2913
|
+
set: number;
|
|
2914
|
+
other: number;
|
|
2915
|
+
/** The tileset's groups the block was found in. */
|
|
2916
|
+
first: number;
|
|
2917
|
+
last: number;
|
|
2918
|
+
/** Piece of E (`group << 4 | slot`) → the tile standing for it. Pieces that are S alone map to the copy's own tile. */
|
|
2919
|
+
pieces: [
|
|
2920
|
+
number,
|
|
2921
|
+
number
|
|
2922
|
+
][];
|
|
2923
|
+
/** E's halves (groups) the brush can ask for, and those of them with no tile at all. */
|
|
2924
|
+
askable: number[];
|
|
2925
|
+
missing: number[];
|
|
2926
|
+
/** The gate's measures: share of minitiles with the source's walk bit and the copy's raise; share of pieces whose buildable bit changes as the copy's. */
|
|
2927
|
+
flags: number;
|
|
2928
|
+
build: number;
|
|
2929
|
+
status: CopyStatus;
|
|
2930
|
+
}
|
|
2931
|
+
export interface EdgeSetInfo {
|
|
2932
|
+
index: number;
|
|
2933
|
+
/** The flat terrains its soft links name. */
|
|
2934
|
+
terrains: number[];
|
|
2935
|
+
/** Even groups (a rect's left half; the right is the next group). */
|
|
2936
|
+
groups: number[];
|
|
2937
|
+
/** Its two terrains stand at different heights: a cliff set. */
|
|
2938
|
+
cliff: boolean;
|
|
2939
|
+
}
|
|
2940
|
+
/** The tileset's edge sets (the era's second half of terrain types), read off its own CV5. */
|
|
2941
|
+
export declare function edgeSetsOf(ts: Tileset, era: number): EdgeSetInfo[];
|
|
2942
|
+
interface FindOptions$1 {
|
|
2943
|
+
/** Awaited between edge sets (the page's sliced path gives a frame there). */
|
|
2944
|
+
pause?: () => Promise<void>;
|
|
2945
|
+
signal?: AbortSignal;
|
|
2946
|
+
}
|
|
2947
|
+
/**
|
|
2948
|
+
* The blocks standing for an edge set of a copied terrain, flat-to-flat sets only (a cliff set's faces carry their own
|
|
2949
|
+
* walk and height bits: measured, none passes the gate). Each block is mapped piece by piece and gated; blocks that
|
|
2950
|
+
* did not reach `MIN_SHAPES` / `MIN_SHARE`, or lost their groups to another set of the same copy, are left out.
|
|
2951
|
+
*/
|
|
2952
|
+
export declare function findCopyBlocks(ts: Tileset, era: number, copies: readonly CopySource[], opts?: FindOptions$1): Promise<CopyBlock[]>;
|
|
2953
|
+
/**
|
|
2954
|
+
* The gate: which of the set's halves the brush can ask for (the first group the tileset holds for its rect's link hash:
|
|
2955
|
+
* `IsomPass.updateTile` takes that one), which of them have no tile, and whether the drawn pieces walk as their source
|
|
2956
|
+
* pieces and stand as high as the copy raises them (`GATE_FLAGS` of the minitiles), their buildable bit changing as the
|
|
2957
|
+
* copy's does. "rejected" fails the flags (not offered), "incomplete" misses a shape (offered, marked), else "complete".
|
|
2958
|
+
* Pieces mapped to the copy's own tiles (S alone) are not drawn pieces.
|
|
2959
|
+
*/
|
|
2960
|
+
export declare function gateBlock(ts: Tileset, era: number, b: {
|
|
2961
|
+
source: number;
|
|
2962
|
+
flat: number;
|
|
2963
|
+
raise: number;
|
|
2964
|
+
set: number;
|
|
2965
|
+
pieces: readonly (readonly [
|
|
2966
|
+
number,
|
|
2967
|
+
number
|
|
2968
|
+
])[];
|
|
2969
|
+
}): Pick<CopyBlock, "askable" | "missing" | "flags" | "build" | "status">;
|
|
2970
|
+
/** Two hashes of a block's tiles' pictures, in order: the same block's key when a mod update moves its groups. */
|
|
2971
|
+
export declare function blockKey(ts: Tileset, tiles: readonly number[]): string;
|
|
2972
|
+
/** The blocks as kept (JSON). */
|
|
2973
|
+
export declare const encodeCopyBlocks: (blocks: readonly CopyBlock[]) => string;
|
|
2974
|
+
/** The blocks back, or null when the text is not a list of them. */
|
|
2975
|
+
export declare function decodeCopyBlocks(text: unknown): CopyBlock[] | null;
|
|
2976
|
+
/**
|
|
2977
|
+
* A terrain id at or above this names a copied terrain for the isometric brush: `COPIED_TERRAIN + (height << 8) + CV5
|
|
2978
|
+
* index`. The editor's own, never written to a map (as the pair and borrowed ids).
|
|
2979
|
+
*/
|
|
2980
|
+
export declare const COPIED_TERRAIN = 294912;
|
|
2981
|
+
export declare const copiedTerrainId: (source: number, height: number) => number;
|
|
2982
|
+
export declare const isCopiedTerrain: (id: number) => boolean;
|
|
2983
|
+
export declare const copiedParts: (id: number) => {
|
|
2984
|
+
source: number;
|
|
2985
|
+
height: number;
|
|
2986
|
+
};
|
|
2987
|
+
/** A ground a block can be drawn to meet: a typed flat terrain (`t<index>`) or an untyped flat pair (`p<even group>`). */
|
|
2988
|
+
export interface CopyGround {
|
|
2989
|
+
id: string;
|
|
2990
|
+
kind: "typed" | "pair";
|
|
2991
|
+
index: number;
|
|
2992
|
+
group: number;
|
|
2993
|
+
}
|
|
2994
|
+
/** A ground with what the seam step and the paint-and-count said of it. */
|
|
2995
|
+
export interface RankedGround extends CopyGround {
|
|
2996
|
+
step: number;
|
|
2997
|
+
flags: number;
|
|
2998
|
+
count?: number;
|
|
2999
|
+
}
|
|
3000
|
+
/** The tileset's grounds: every typed flat terrain (all its flat groups) and every loose pair. */
|
|
3001
|
+
export declare function groundsOf(ts: Tileset, era: number): Map<string, CopyGround & {
|
|
3002
|
+
megas: number[];
|
|
3003
|
+
}>;
|
|
3004
|
+
/** A block made ready to lay, with the outer ground it is laid against. */
|
|
3005
|
+
export interface CopyTable {
|
|
3006
|
+
ts: Tileset;
|
|
3007
|
+
era: number;
|
|
3008
|
+
block: CopyBlock;
|
|
3009
|
+
/** S's typed flat groups (even), O's first flat group. */
|
|
3010
|
+
sGroups: Set<number>;
|
|
3011
|
+
oGroup: number;
|
|
3012
|
+
/** Piece → tile; per E half the tiles held for it (any slot). */
|
|
3013
|
+
tileOf: Map<number, number>;
|
|
3014
|
+
halfTiles: Map<number, number[]>;
|
|
3015
|
+
/** The copy's tiles by side (0 left, 1 right) and slot. */
|
|
3016
|
+
sTiles: [
|
|
3017
|
+
number[],
|
|
3018
|
+
number[]
|
|
3019
|
+
];
|
|
3020
|
+
outer: CopyGround;
|
|
3021
|
+
gTiles: [
|
|
3022
|
+
number[],
|
|
3023
|
+
number[]
|
|
3024
|
+
];
|
|
3025
|
+
/** The tiles a cell with no drawn piece chooses from (by its joins). */
|
|
3026
|
+
pool: number[];
|
|
3027
|
+
}
|
|
3028
|
+
export declare function copyTable(ts: Tileset, era: number, block: CopyBlock, outer: CopyGround): CopyTable;
|
|
3029
|
+
/** The archive member holding the copied terrains' footprints (`scmjs\copies.bin`). */
|
|
3030
|
+
export declare const COPY_MEMBER = "scmjs\\copies.bin";
|
|
3031
|
+
/**
|
|
3032
|
+
* One patch: the terrain (S and the height), the block (`CopyBlock.key`, its pictures' hash, so the block is found again
|
|
3033
|
+
* when a mod update moves its groups), the outer ground it was laid against (`t<terrain>` / `p<pair group>`) and the
|
|
3034
|
+
* diamonds painted (`y * (isomWidth + 1) + x`).
|
|
3035
|
+
*/
|
|
3036
|
+
export interface CopyPatch {
|
|
3037
|
+
source: number;
|
|
3038
|
+
height: number;
|
|
3039
|
+
key: string;
|
|
3040
|
+
ground: string;
|
|
3041
|
+
diamonds: Set<number>;
|
|
3042
|
+
}
|
|
3043
|
+
/**
|
|
3044
|
+
* The member for a set of patches: "CPY1", width, height (u16 LE), ERA, 0, patch count (u16); per patch S (u8), height
|
|
3045
|
+
* (u8), key length (u8) and key (ASCII), ground length (u8) and ground (ASCII), diamond count (u32), the diamonds (u32).
|
|
3046
|
+
* Null when no patch has a diamond.
|
|
3047
|
+
*/
|
|
3048
|
+
export declare function encodeCopyMember(size: {
|
|
3049
|
+
width: number;
|
|
3050
|
+
height: number;
|
|
3051
|
+
}, era: number, patches: readonly CopyPatch[]): Uint8Array | null;
|
|
3052
|
+
/** The patches a member holds for a map of this size and tileset, or [] when it is not ours, for another size or ERA. */
|
|
3053
|
+
export declare function decodeCopyMember(member: Uint8Array | null | undefined, size: {
|
|
3054
|
+
width: number;
|
|
3055
|
+
height: number;
|
|
3056
|
+
}, era: number): CopyPatch[];
|
|
3057
|
+
/** The member after a resize that moved the map's old top-left tile to (dx, dy): diamonds move by whole rects; an odd column shift drops it. */
|
|
3058
|
+
export declare function resizeCopyMember(member: Uint8Array | null, from: {
|
|
3059
|
+
width: number;
|
|
3060
|
+
height: number;
|
|
3061
|
+
}, to: {
|
|
3062
|
+
width: number;
|
|
3063
|
+
height: number;
|
|
3064
|
+
}, era: number, dx: number, dy: number): Uint8Array | null;
|
|
3065
|
+
export interface CopyPaint {
|
|
3066
|
+
/** Changes the game's brush already applied laying the outer ground (tiles), and its lattice changes. */
|
|
3067
|
+
applied: TileChange[];
|
|
3068
|
+
isom: TileChange[];
|
|
3069
|
+
/** The translated cells, for the caller to apply. */
|
|
3070
|
+
changes: TileChange[];
|
|
3071
|
+
}
|
|
3072
|
+
export interface CopyStrokeResult {
|
|
3073
|
+
before: Uint8Array | null;
|
|
3074
|
+
after: Uint8Array | null;
|
|
3075
|
+
/** Cells laid with no drawn piece for their shape (the block is incomplete there). */
|
|
3076
|
+
missing: number;
|
|
3077
|
+
/** Diamonds not laid: the outer ground is an untyped pair and was not under them. */
|
|
3078
|
+
refused: number;
|
|
3079
|
+
/** Cells the brush would have written and did not, because they are pinned. */
|
|
3080
|
+
kept: number[];
|
|
3081
|
+
}
|
|
3082
|
+
/**
|
|
3083
|
+
* One stroke of a copied terrain on a map: built from the member as the stroke starts, fed diamonds as the pointer moves
|
|
3084
|
+
* (`paint`), finished once. `table` is the block chosen for the stroke (`chooseBlock`).
|
|
3085
|
+
*/
|
|
3086
|
+
export declare class CopyStroke {
|
|
3087
|
+
readonly t: CopyTable;
|
|
3088
|
+
private readonly scn;
|
|
3089
|
+
private readonly pinned;
|
|
3090
|
+
private readonly random;
|
|
3091
|
+
private readonly shadow;
|
|
3092
|
+
private readonly patches;
|
|
3093
|
+
private readonly patch;
|
|
3094
|
+
readonly before: Uint8Array | null;
|
|
3095
|
+
private readonly missingAt;
|
|
3096
|
+
private readonly keptAt;
|
|
3097
|
+
private refused;
|
|
3098
|
+
constructor(scn: Scenario, t: CopyTable, before: Uint8Array | null, pinned?: Uint8Array | null, random?: () => number);
|
|
3099
|
+
/** Whether a diamond can be laid: with a pair for outer ground, its rects (and the ring's) must be that ground already, or the patch. */
|
|
3100
|
+
private onGround;
|
|
3101
|
+
/** Paint the copied terrain on `diamonds`. */
|
|
3102
|
+
paint(diamonds: readonly Diamond[]): CopyPaint;
|
|
3103
|
+
finish(): CopyStrokeResult;
|
|
3104
|
+
}
|
|
3105
|
+
export interface RelayResult {
|
|
3106
|
+
changes: TileChange[];
|
|
3107
|
+
after: Uint8Array | null;
|
|
3108
|
+
/** Diamonds given up (the lattice under them is not the outer ground any more, or their tiles were written over). */
|
|
3109
|
+
dropped: number;
|
|
3110
|
+
/** Joins that show between a re-laid cell and a cell the patch could not keep. */
|
|
3111
|
+
hard: number;
|
|
3112
|
+
}
|
|
3113
|
+
/**
|
|
3114
|
+
* After an isometric stroke of another terrain (the game's brush, a borrowed one) or another tool wrote over a patch:
|
|
3115
|
+
* every patch keeps the footprint diamonds the real lattice still holds as its outer ground (typed) with their four
|
|
3116
|
+
* neighbours too, so the shadow's edge ring stands on it; a diamond whose rects hold a tile the patch could not have
|
|
3117
|
+
* laid is given up. Footprint diamonds are then given up until every cell the shadow names lies on rects of the outer
|
|
3118
|
+
* ground alone (the shrink that removes the hard cut). The shadow is laid again, its cells written, and cells the patch
|
|
3119
|
+
* held that are outside it now go back to the outer ground's own tile where the lattice is that ground.
|
|
3120
|
+
* `tableOf` resolves a patch to its block's table (null: the block is not known, the patch is left alone).
|
|
3121
|
+
*/
|
|
3122
|
+
export declare function relayCopies(scn: Scenario, member: Uint8Array | null, era: number, tableOf: (p: CopyPatch) => CopyTable | null, opts?: {
|
|
3123
|
+
pinned?: Uint8Array | null;
|
|
3124
|
+
random?: () => number;
|
|
3125
|
+
touched?: Iterable<number>;
|
|
3126
|
+
shrink?: boolean;
|
|
3127
|
+
}): RelayResult;
|
|
3128
|
+
/**
|
|
3129
|
+
* Paint and count: the fixed strokes painted with the block on a map of `t.outer`, each on a fresh map; joins showing
|
|
3130
|
+
* (`SEAM_SHOWS`) per 100 border cells (cells where the shadow lays a piece). What the brush would show on that ground.
|
|
3131
|
+
*/
|
|
3132
|
+
export declare function paintCount(t: CopyTable): number;
|
|
3133
|
+
/**
|
|
3134
|
+
* The grounds a block could be drawn to meet, ranked by the mean seam step across the pieces' outer sides (the sides
|
|
3135
|
+
* whose link is O's), each ground's tiles averaged as the brush lays any of them; ties by the share of the repainted
|
|
3136
|
+
* minitiles whose VF4 word the ground carries. The block's own rows (they look like loose pairs), S's own ground and the
|
|
3137
|
+
* copy are left out.
|
|
3138
|
+
*/
|
|
3139
|
+
export declare function rankGrounds(ts: Tileset, era: number, block: CopyBlock): RankedGround[];
|
|
3140
|
+
/** The outer ground among counted candidates: the lowest count, then within `COUNT_MARGIN` the flags and typed before a pair. */
|
|
3141
|
+
export declare function chooseOuter(ranked: readonly RankedGround[]): RankedGround | null;
|
|
3142
|
+
/**
|
|
3143
|
+
* The ground under and around a stroke's first diamonds: the commonest ground of the cells of their rects and the rects
|
|
3144
|
+
* around them. Null when none of them is a ground.
|
|
3145
|
+
*/
|
|
3146
|
+
export declare function groundUnder(scn: Scenario, ts: Tileset, era: number, diamonds: readonly Diamond[]): string | null;
|
|
3147
|
+
/** The patch of the same terrain that a stroke starting on `d` continues (a footprint diamond within one of it), if any. */
|
|
3148
|
+
export declare function patchAt(member: Uint8Array | null, size: {
|
|
3149
|
+
width: number;
|
|
3150
|
+
height: number;
|
|
3151
|
+
}, era: number, source: number, height: number, d: Diamond): CopyPatch | null;
|
|
3152
|
+
export interface BorderCell {
|
|
3153
|
+
/** The cell, row-major. */
|
|
3154
|
+
i: number;
|
|
3155
|
+
/** Its shape (`borderLattice.ts`), and the pair whose table it is laid from. */
|
|
3156
|
+
shape: string;
|
|
3157
|
+
table: BorderPairTable;
|
|
3158
|
+
/** Leans to the patch: the hard edge there is the patch's tile (`xTile`), else the ground's own tile before. */
|
|
3159
|
+
leansX: boolean;
|
|
3160
|
+
xTile: number;
|
|
3161
|
+
}
|
|
3162
|
+
export interface BorderPassResult {
|
|
3163
|
+
/** Cells laid with a tile of the table or the pool. */
|
|
3164
|
+
drawn: number;
|
|
3165
|
+
fromPool: number;
|
|
3166
|
+
/** Cells left as the hard edge: no candidate joins there. */
|
|
3167
|
+
hard: number;
|
|
3168
|
+
/** Cells on the ground's side where the tile that was there joins and stays. */
|
|
3169
|
+
kept: number;
|
|
3170
|
+
/** The cells (indices) left hard, and kept. */
|
|
3171
|
+
hardCells: number[];
|
|
3172
|
+
keptCells: number[];
|
|
3173
|
+
ms: number;
|
|
3174
|
+
}
|
|
3175
|
+
/** Work out the measures the pass reads (the tileset's edges, their grain and means) ahead of the first stroke. */
|
|
3176
|
+
export declare function warmBorderPass(host: Tileset): void;
|
|
3177
|
+
/**
|
|
3178
|
+
* Lay `cells` into `tiles` (the map as it will be around them: the patch laid, the ground as it was), `before` the
|
|
3179
|
+
* ground's own tiles. `pools` gives the sheet's further candidates per table.
|
|
3180
|
+
*/
|
|
3181
|
+
export declare function layBorder(host: Tileset, w: number, h: number, tiles: Uint16Array, cells: readonly BorderCell[], before: ArrayLike<number>, pools: ReadonlyMap<BorderPairTable, readonly number[]>, opts?: {
|
|
3182
|
+
keepGround?: boolean;
|
|
3183
|
+
}): BorderPassResult;
|
|
3184
|
+
type Size$1 = Pick<Scenario, "width" | "height">;
|
|
3185
|
+
/** The member holding the border record for tileset `sourceEra` (`scmjs\borders-install.bin`). */
|
|
3186
|
+
export declare const bordersMember: (sourceEra: number) => string;
|
|
3187
|
+
export declare const BORDER_MEMBERS: readonly string[];
|
|
3188
|
+
export interface BorderRecord {
|
|
3189
|
+
/** Diamonds (`y * (isomWidth + 1) + x`) the borrowed brush painted and nothing took back → the terrain painted. */
|
|
3190
|
+
painted: Map<number, number>;
|
|
3191
|
+
/** Cell → the host tile it had before the borrowed brush first wrote it. */
|
|
3192
|
+
cells: Map<number, number>;
|
|
3193
|
+
}
|
|
3194
|
+
export declare const emptyRecord: () => BorderRecord;
|
|
3195
|
+
export declare function encodeBorderRecord(size: Size$1, sourceEra: number, r: BorderRecord): Uint8Array | null;
|
|
3196
|
+
/** The record a member holds for a map of this size and source; null when it is not one, or for another size. */
|
|
3197
|
+
export declare function decodeBorderRecord(member: Uint8Array | null | undefined, size: Size$1, sourceEra: number): BorderRecord | null;
|
|
3198
|
+
/** The member after a resize that moved the old top-left tile to (dx, dy); null when nothing is left or `dx` is odd. */
|
|
3199
|
+
export declare function resizeBorderRecord(member: Uint8Array | null, from: Size$1, to: Size$1, sourceEra: number, dx: number, dy: number): Uint8Array | null;
|
|
2368
3200
|
export interface DoodadDef {
|
|
2369
3201
|
/** The `dddata.bin` index, which DD2 records store. */
|
|
2370
3202
|
id: number;
|
|
@@ -2436,6 +3268,8 @@ export interface DoodadPlacementOptions {
|
|
|
2436
3268
|
snapToGrid: boolean;
|
|
2437
3269
|
/** Place as plain terrain: the tiles (both sections) and any overlay sprite, no DD2 record — a placement and a conversion in one. */
|
|
2438
3270
|
asTerrain: boolean;
|
|
3271
|
+
/** Pin the tiles of a doodad that goes down as terrain (a stretched one always does), so the brushes that lay terrain by rule leave it (editor/pins.ts). */
|
|
3272
|
+
pin: boolean;
|
|
2439
3273
|
}
|
|
2440
3274
|
export declare const DEFAULT_DOODAD_PLACEMENT: DoodadPlacementOptions;
|
|
2441
3275
|
export interface DoodadVerdict {
|
|
@@ -2463,6 +3297,350 @@ export declare function checkDoodadPlacement(scn: Scenario, tileset: Tileset | n
|
|
|
2463
3297
|
* with the old copy removed). Nothing is applied.
|
|
2464
3298
|
*/
|
|
2465
3299
|
export declare function placeDoodad(scn: Scenario, def: DoodadDef, tx: number, ty: number, owner: number, tileAt?: (at: number) => number): DoodadEdit;
|
|
3300
|
+
/** Slots in a CV5 group: the sheet's width. */
|
|
3301
|
+
export declare const SHEET_COLUMNS = 16;
|
|
3302
|
+
/**
|
|
3303
|
+
* The most empty groups (no slot with a picture) that may stand between two listed groups and
|
|
3304
|
+
* still count as one run: they are laid as void rows, so a picture with an empty row inside it
|
|
3305
|
+
* stays whole. Measured over the game's eight tilesets and Cosmonarchy's: gaps of one to four
|
|
3306
|
+
* empty groups are common inside the mod's pictures, and the game's own long empty stretches
|
|
3307
|
+
* (hundreds of groups between terrain and doodads) are far past this.
|
|
3308
|
+
*/
|
|
3309
|
+
export declare const SHEET_BRIDGE = 16;
|
|
3310
|
+
export interface SheetRow {
|
|
3311
|
+
/** The CV5 group this row shows. */
|
|
3312
|
+
group: number;
|
|
3313
|
+
/** Which run the row belongs to: rows of one run are consecutive groups; a drag stays inside one. */
|
|
3314
|
+
run: number;
|
|
3315
|
+
/** A row bridged in between two listed groups: an empty group, drawn as void. */
|
|
3316
|
+
blank: boolean;
|
|
3317
|
+
}
|
|
3318
|
+
/**
|
|
3319
|
+
* The sheet's rows for the listed groups (ascending, as the palette's filter and search leave
|
|
3320
|
+
* them): consecutive groups share a run; a gap of no more than `bridge` groups that `isEmpty`
|
|
3321
|
+
* calls empty is filled with blank rows of the same run; any other gap starts a new run.
|
|
3322
|
+
*/
|
|
3323
|
+
export declare function sheetRows(listed: readonly number[], isEmpty?: (group: number) => boolean, bridge?: number): SheetRow[];
|
|
3324
|
+
/** The first and last row (inclusive) of the run `row` is in. */
|
|
3325
|
+
export declare function runBounds(rows: readonly SheetRow[], row: number): {
|
|
3326
|
+
first: number;
|
|
3327
|
+
last: number;
|
|
3328
|
+
};
|
|
3329
|
+
/** A tile id written nowhere: a slot of the block that is left as the map has it. */
|
|
3330
|
+
export declare const HOLE = -1;
|
|
3331
|
+
/**
|
|
3332
|
+
* A rectangle of tiles picked from the sheet: `ids` row by row, `cols` × `rows` of them, a void
|
|
3333
|
+
* slot as {@link HOLE}. `origin` is where its top-left came from, for the sheet's outline.
|
|
3334
|
+
*/
|
|
3335
|
+
export interface TileBlock {
|
|
3336
|
+
cols: number;
|
|
3337
|
+
rows: number;
|
|
3338
|
+
ids: number[];
|
|
3339
|
+
origin?: {
|
|
3340
|
+
group: number;
|
|
3341
|
+
slot: number;
|
|
3342
|
+
};
|
|
3343
|
+
}
|
|
3344
|
+
/** A sheet rectangle in rows and slots, both ends inclusive, in either order. */
|
|
3345
|
+
export interface SheetRect {
|
|
3346
|
+
row0: number;
|
|
3347
|
+
col0: number;
|
|
3348
|
+
row1: number;
|
|
3349
|
+
col1: number;
|
|
3350
|
+
}
|
|
3351
|
+
/**
|
|
3352
|
+
* The block a rectangle of the sheet picks: null when it crosses a break between runs, leaves
|
|
3353
|
+
* the sheet, or holds no tile at all. `isVoid(id)` says which slots have no picture (the null
|
|
3354
|
+
* megatile); those and blank rows become holes.
|
|
3355
|
+
*/
|
|
3356
|
+
export declare function blockFromRect(rows: readonly SheetRow[], rect: SheetRect, isVoid: (id: number) => boolean): TileBlock | null;
|
|
3357
|
+
/** The block's first tile that is not a hole (what the Tile brush's single tile becomes), or HOLE. */
|
|
3358
|
+
export declare function firstTile(block: TileBlock): number;
|
|
3359
|
+
/** Where on the sheet a block came from, as a rect, or null when its rows are not listed now. */
|
|
3360
|
+
export declare function blockRect(rows: readonly SheetRow[], block: TileBlock): SheetRect | null;
|
|
3361
|
+
/** The cells of `block` laid with its top-left at map cell (x, y): holes and cells off the map left out. */
|
|
3362
|
+
export declare function blockCells(block: TileBlock, x: number, y: number, width: number, height: number): {
|
|
3363
|
+
x: number;
|
|
3364
|
+
y: number;
|
|
3365
|
+
id: number;
|
|
3366
|
+
}[];
|
|
3367
|
+
/** The changes laying `block` at (x, y) would make: holes and cells off the map skipped, tiles already right too. */
|
|
3368
|
+
export declare function layBlock(scn: Scenario, block: TileBlock, x: number, y: number): TileChange[];
|
|
3369
|
+
/**
|
|
3370
|
+
* The top-left of the copy of the pattern under map cell (x, y), for a drag that started with
|
|
3371
|
+
* the block's top-left at `origin`: origin + (i·cols, j·rows) for the block cell the pointer is in.
|
|
3372
|
+
*/
|
|
3373
|
+
export declare function patternOrigin(block: Pick<TileBlock, "cols" | "rows">, origin: {
|
|
3374
|
+
x: number;
|
|
3375
|
+
y: number;
|
|
3376
|
+
}, x: number, y: number): {
|
|
3377
|
+
x: number;
|
|
3378
|
+
y: number;
|
|
3379
|
+
};
|
|
3380
|
+
/** The pattern's tile at map cell (x, y) when its copies are laid from `origin`, or HOLE. */
|
|
3381
|
+
export declare function patternTileAt(block: TileBlock, origin: {
|
|
3382
|
+
x: number;
|
|
3383
|
+
y: number;
|
|
3384
|
+
}, x: number, y: number): number;
|
|
3385
|
+
/** The changes tiling `cells` (map indices) with the pattern laid from `origin`; holes leave a cell as it is. */
|
|
3386
|
+
export declare function layPattern(scn: Scenario, block: TileBlock, origin: {
|
|
3387
|
+
x: number;
|
|
3388
|
+
y: number;
|
|
3389
|
+
}, cells: Iterable<number>): TileChange[];
|
|
3390
|
+
/**
|
|
3391
|
+
* One drag of a block: the press sets the origin, and each cell the pointer reaches lays the copy
|
|
3392
|
+
* of the block it falls in, once. What it answers goes into the stroke's change list like any
|
|
3393
|
+
* brush's, so the whole drag is one undo step.
|
|
3394
|
+
*/
|
|
3395
|
+
export declare class PatternStroke {
|
|
3396
|
+
private readonly laid;
|
|
3397
|
+
readonly block: TileBlock;
|
|
3398
|
+
readonly origin: {
|
|
3399
|
+
x: number;
|
|
3400
|
+
y: number;
|
|
3401
|
+
};
|
|
3402
|
+
constructor(block: TileBlock, origin: {
|
|
3403
|
+
x: number;
|
|
3404
|
+
y: number;
|
|
3405
|
+
});
|
|
3406
|
+
/** The changes for the copy under (x, y), or none when that copy is already down in this drag. */
|
|
3407
|
+
at(scn: Scenario, x: number, y: number): TileChange[];
|
|
3408
|
+
/** How many copies the drag has laid. */
|
|
3409
|
+
get copies(): number;
|
|
3410
|
+
}
|
|
3411
|
+
/** What maps have shown about one tileset's sheet. Tiles are `group << 4 | slot`. */
|
|
3412
|
+
export interface PieceEvidence {
|
|
3413
|
+
/** How many maps were counted. */
|
|
3414
|
+
maps: number;
|
|
3415
|
+
/** Times each tile is laid. */
|
|
3416
|
+
laid: Map<number, number>;
|
|
3417
|
+
/** Times a tile has its sheet's right neighbour (same group, next slot) on its right. */
|
|
3418
|
+
across: Map<number, number>;
|
|
3419
|
+
/** Times a tile has its sheet's lower neighbour (next group, same slot) below it. */
|
|
3420
|
+
down: Map<number, number>;
|
|
3421
|
+
}
|
|
3422
|
+
export interface Piece {
|
|
3423
|
+
/** Its tiles, ascending: `group << 4 | slot`. */
|
|
3424
|
+
tiles: number[];
|
|
3425
|
+
/** The sheet rectangle around it, in slots and groups. */
|
|
3426
|
+
slot: number;
|
|
3427
|
+
group: number;
|
|
3428
|
+
cols: number;
|
|
3429
|
+
rows: number;
|
|
3430
|
+
/** Times its tiles are laid, all told: how much maps use it. */
|
|
3431
|
+
laid: number;
|
|
3432
|
+
}
|
|
3433
|
+
export interface CutOptions {
|
|
3434
|
+
/**
|
|
3435
|
+
* A join holds when the two tiles are laid together at least this share of the times the
|
|
3436
|
+
* rarer of them is laid at all.
|
|
3437
|
+
*/
|
|
3438
|
+
share: number;
|
|
3439
|
+
}
|
|
3440
|
+
/** Half: a picture's tiles are together nearly always, loose ground about one time in sixteen. */
|
|
3441
|
+
export declare const DEFAULT_CUT: CutOptions;
|
|
3442
|
+
export declare function emptyEvidence(): PieceEvidence;
|
|
3443
|
+
export type Sheet = Pick<Tileset, "groups">;
|
|
3444
|
+
/**
|
|
3445
|
+
* Count one map. A doodad group's tiles are left out (a doodad is already a whole thing, and
|
|
3446
|
+
* has its own palette), and so is a slot with no picture.
|
|
3447
|
+
*/
|
|
3448
|
+
export declare function gatherEvidence(into: PieceEvidence, tiles: ArrayLike<number>, width: number, height: number, tileset: Sheet): PieceEvidence;
|
|
3449
|
+
/** Two bodies of evidence as one (a learned collection and the map in front). */
|
|
3450
|
+
export declare function mergeEvidence(a: PieceEvidence, b: PieceEvidence): PieceEvidence;
|
|
3451
|
+
/** The pieces the evidence shows, in sheet order. */
|
|
3452
|
+
export declare function cutPieces(evidence: PieceEvidence, options?: CutOptions): Piece[];
|
|
3453
|
+
/** A piece as a block the Tile brush lays: its sheet rectangle, a hole where it has no tile. */
|
|
3454
|
+
export declare function pieceBlock(piece: Piece): TileBlock;
|
|
3455
|
+
/** The piece a tile belongs to, by tile: built once per list. */
|
|
3456
|
+
export declare function pieceIndex(pieces: readonly Piece[]): Map<number, Piece>;
|
|
3457
|
+
/** Evidence as plain numbers, for keeping: `[maps, laid…, -1, across…, -1, down…]` in pairs. */
|
|
3458
|
+
export declare function encodeEvidence(e: PieceEvidence): number[];
|
|
3459
|
+
export declare function decodeEvidence(data: readonly number[]): PieceEvidence | null;
|
|
3460
|
+
/** A map to read: its name for the report and its bytes when asked. */
|
|
3461
|
+
export interface LearnFile {
|
|
3462
|
+
name: string;
|
|
3463
|
+
bytes(): Promise<Uint8Array>;
|
|
3464
|
+
}
|
|
3465
|
+
export type SkipReason = "unreadable" | "notOurs" | "noTiles";
|
|
3466
|
+
export interface LearnResult {
|
|
3467
|
+
/** Maps counted. */
|
|
3468
|
+
read: number;
|
|
3469
|
+
/** The tables counted against, by ERA index: what the evidence is about (`tableHash`). */
|
|
3470
|
+
tables: Map<number, readonly Cv5Group[]>;
|
|
3471
|
+
/** Maps left out, and why. */
|
|
3472
|
+
skipped: {
|
|
3473
|
+
name: string;
|
|
3474
|
+
reason: SkipReason;
|
|
3475
|
+
}[];
|
|
3476
|
+
/** The evidence by ERA index (0–7), for every tileset at least one map was counted on. */
|
|
3477
|
+
evidence: Map<number, PieceEvidence>;
|
|
3478
|
+
/** Drawn borders' evidence by ERA index, for every tileset `LearnDeps.borders` gave a setup for. */
|
|
3479
|
+
borders: Map<number, BorderEvidence>;
|
|
3480
|
+
}
|
|
3481
|
+
export interface LearnDeps {
|
|
3482
|
+
/** A tileset's CV5 groups as the data set in use has them, or null when it has none. */
|
|
3483
|
+
groups(era: number): Promise<readonly Cv5Group[] | null>;
|
|
3484
|
+
/** Told after each map: how many are done of how many. */
|
|
3485
|
+
progress?(done: number, total: number): void;
|
|
3486
|
+
/** Awaited between maps so the page can draw; a test passes nothing. */
|
|
3487
|
+
pause?(): Promise<void>;
|
|
3488
|
+
/** True to stop early: what was read so far is kept. */
|
|
3489
|
+
stopped?(): boolean;
|
|
3490
|
+
/**
|
|
3491
|
+
* What drawn borders are read with on a tileset (`borderTable.ts`): its classes (the known sources' copies) and the
|
|
3492
|
+
* stand-ins; null where no source is known. Without it nothing is learned of borders.
|
|
3493
|
+
*/
|
|
3494
|
+
borders?(era: number): Promise<{
|
|
3495
|
+
classes: BorderClasses;
|
|
3496
|
+
standIns: StandIns;
|
|
3497
|
+
} | null>;
|
|
3498
|
+
}
|
|
3499
|
+
/** Whether a file name is a map the editor opens. */
|
|
3500
|
+
export declare const isMapName: (name: string) => boolean;
|
|
3501
|
+
export declare function learnFromMaps(files: readonly LearnFile[], deps: LearnDeps): Promise<LearnResult>;
|
|
3502
|
+
/** How many pieces each learned tileset cuts into, by ERA index. */
|
|
3503
|
+
export declare function piecesPerTileset(result: LearnResult): Map<number, number>;
|
|
3504
|
+
/**
|
|
3505
|
+
* A tileset's table as a short key: a hash of its CV5 records, word for word as the file holds
|
|
3506
|
+
* them (the decoded groups keep all 26 words of a record). Evidence about pieces is evidence
|
|
3507
|
+
* about one table's tile ids, so it is kept under this: the same table reached through any data
|
|
3508
|
+
* set shares it, and a table that changed starts afresh.
|
|
3509
|
+
*/
|
|
3510
|
+
export declare function tableHash(groups: readonly Cv5Group[]): string;
|
|
3511
|
+
/**
|
|
3512
|
+
* A re-dithered copy: every 4 × 4 pixel block's mean colour within this much a channel of the
|
|
3513
|
+
* other picture's, and (below) the cell's mean pixel difference within `COPY_CELL_MEAN`.
|
|
3514
|
+
* Calibrated on the isometric spike's copies, where it passed none of the negative controls.
|
|
3515
|
+
* A mean over the whole piece instead is not safe: a small detail (a console on a wall) is lost
|
|
3516
|
+
* in it, and two pieces that differ only there would fold into one.
|
|
3517
|
+
*/
|
|
3518
|
+
export declare const COPY_BLOCK_MEAN = 2.5;
|
|
3519
|
+
/** The cell's mean difference per pixel, the channels averaged; see `COPY_BLOCK_MEAN`. */
|
|
3520
|
+
export declare const COPY_CELL_MEAN = 10;
|
|
3521
|
+
/** A tile's picture as a key ("" where it has none): equal keys, byte-identical pixels. */
|
|
3522
|
+
export declare function pictureKey(tileset: Tileset, tile: number): string;
|
|
3523
|
+
/** Picture and flags: two tiles with the same key are the same tile to the palette's lists. Kept per tileset. */
|
|
3524
|
+
export declare function sameTileKey(tileset: Tileset, tile: number): string;
|
|
3525
|
+
/**
|
|
3526
|
+
* The tiles of `ids` with every repeat by picture and flags left out, the lowest id of each kept
|
|
3527
|
+
* (so where a mod repeats the game's tile, the game's is the one listed). `exclude` drops the
|
|
3528
|
+
* tiles whose key is among those (the game's part, for the "Added by" filter). Order kept.
|
|
3529
|
+
*/
|
|
3530
|
+
export declare function uniqueTiles(tileset: Tileset, ids: readonly number[], exclude?: ReadonlySet<string>): number[];
|
|
3531
|
+
/** Whether two megatiles show the same picture, exactly or as a re-dithered copy. */
|
|
3532
|
+
export declare function samePicture(tileset: Tileset, a: number, b: number): boolean;
|
|
3533
|
+
/** What tells two tiles of one picture apart to the game, in the words the hover uses. */
|
|
3534
|
+
export type FlagDifference = "height" | "walkable" | "buildable";
|
|
3535
|
+
export interface PieceEntry {
|
|
3536
|
+
/** The piece listed: the most laid of those it stands for. */
|
|
3537
|
+
piece: Piece;
|
|
3538
|
+
/** The others, the same tile cell for cell. */
|
|
3539
|
+
copies: Piece[];
|
|
3540
|
+
/** Set when it is another entry's picture under other flags: that entry, and what differs. */
|
|
3541
|
+
copyOf?: {
|
|
3542
|
+
piece: Piece;
|
|
3543
|
+
differs: FlagDifference[];
|
|
3544
|
+
};
|
|
3545
|
+
}
|
|
3546
|
+
/**
|
|
3547
|
+
* The pieces as the Pieces view lists them: pieces of one outline whose every cell is the same
|
|
3548
|
+
* tile (picture, exact or re-dithered, and flags) are one entry, the most laid kept (ties: the
|
|
3549
|
+
* lowest first tile). A piece that is another's picture under other flags is an entry of its
|
|
3550
|
+
* own, placed right after the one it copies. In sheet order otherwise.
|
|
3551
|
+
*/
|
|
3552
|
+
export declare function collapsePieces(tileset: Tileset, pieces: readonly Piece[]): PieceEntry[];
|
|
3553
|
+
/** Every piece an entry stands for. */
|
|
3554
|
+
export declare const entryPieces: (e: PieceEntry) => Piece[];
|
|
3555
|
+
/** A map tile as the pieces name it: `group << 4 | slot`, the group read as the tileset's size says. */
|
|
3556
|
+
export declare const sheetTile: (raw: number, groupCount: number) => number;
|
|
3557
|
+
export declare function laidPieceAt(map: {
|
|
3558
|
+
tiles: ArrayLike<number>;
|
|
3559
|
+
width: number;
|
|
3560
|
+
height: number;
|
|
3561
|
+
}, groupCount: number, index: ReadonlyMap<number, Piece>, x: number, y: number): Piece | null;
|
|
3562
|
+
export interface TerrainType extends TerrainName {
|
|
3563
|
+
/** Even CV5 group of the flat pair; odd columns use `group + 1`. */
|
|
3564
|
+
group: number;
|
|
3565
|
+
height: 0 | 1 | 2;
|
|
3566
|
+
buildable: boolean;
|
|
3567
|
+
/**
|
|
3568
|
+
* The name in the user's language, where `name` is not a string of the catalogue's: a pair
|
|
3569
|
+
* terrain's name is put together ("Mud (mid ground)", "Group 3672"). Shown through `terrainLabel`.
|
|
3570
|
+
*/
|
|
3571
|
+
label?: string;
|
|
3572
|
+
}
|
|
3573
|
+
/** One named piece a plugin provides: a block of tiles, as `blockFrom` or `blockOf` give them. */
|
|
3574
|
+
export interface ProvidedPiece {
|
|
3575
|
+
name?: string;
|
|
3576
|
+
category?: string;
|
|
3577
|
+
block: TileBlock;
|
|
3578
|
+
}
|
|
3579
|
+
/** A plugin's set of pieces, as the host keeps it: `key` is the plugin's id and the set's. */
|
|
3580
|
+
export interface ProvidedPieceSet {
|
|
3581
|
+
key: string;
|
|
3582
|
+
/** The providing plugin's id. */
|
|
3583
|
+
source: string;
|
|
3584
|
+
label: string;
|
|
3585
|
+
pieces: readonly ProvidedPiece[];
|
|
3586
|
+
}
|
|
3587
|
+
/** Flat ground a plugin declares: a name for the pair whose left half is `group` (even). */
|
|
3588
|
+
export interface DeclaredTerrain {
|
|
3589
|
+
name: string;
|
|
3590
|
+
group: number;
|
|
3591
|
+
}
|
|
3592
|
+
export interface ListedPiece {
|
|
3593
|
+
block: TileBlock;
|
|
3594
|
+
/** Its tiles, ascending, holes left out. */
|
|
3595
|
+
tiles: number[];
|
|
3596
|
+
/** Where its top-left is in the sheet: the block's origin, else its lowest tile's group and slot. */
|
|
3597
|
+
group: number;
|
|
3598
|
+
slot: number;
|
|
3599
|
+
name?: string;
|
|
3600
|
+
category?: string;
|
|
3601
|
+
/** `"maps"` for a cut piece, else the providing plugin's id, or `@dataset:<id>` for a data set's terrain file. */
|
|
3602
|
+
source: string;
|
|
3603
|
+
/** Times its tiles are laid, all told (0 for a provided piece). */
|
|
3604
|
+
laid: number;
|
|
3605
|
+
/** A cut piece's entry: the copies it stands for, and what it copies under other flags. */
|
|
3606
|
+
entry?: PieceEntry;
|
|
3607
|
+
}
|
|
3608
|
+
export interface PieceSection {
|
|
3609
|
+
/** The providing set's label; null for the pieces cut from maps. */
|
|
3610
|
+
label: string | null;
|
|
3611
|
+
source: string;
|
|
3612
|
+
items: ListedPiece[];
|
|
3613
|
+
}
|
|
3614
|
+
/** A block's tiles, ascending, each once, holes left out. */
|
|
3615
|
+
export declare function blockTiles(block: TileBlock): number[];
|
|
3616
|
+
/** Whether every tile of a block has a picture in the loaded table (a group past it has none). */
|
|
3617
|
+
export declare function blockFits(tileset: Pick<Tileset, "groups" | "megatileCount">, block: TileBlock): boolean;
|
|
3618
|
+
/**
|
|
3619
|
+
* The sections the Pieces view shows: each provided set that has a piece the table holds, in
|
|
3620
|
+
* the order given, then the cut pieces less those a provided piece already names.
|
|
3621
|
+
*/
|
|
3622
|
+
export declare function pieceSections(tileset: Pick<Tileset, "groups" | "megatileCount">, entries: readonly PieceEntry[], sets: readonly ProvidedPieceSet[]): PieceSection[];
|
|
3623
|
+
/**
|
|
3624
|
+
* Declared flat ground as Rect brush terrains: the pair terrain of each group (`pairTerrain`,
|
|
3625
|
+
* so it lays, fills and replaces as a picked pair does) under the name the plugin gave. A group
|
|
3626
|
+
* that is not a pair in the loaded table is skipped, and so is one already listed.
|
|
3627
|
+
*/
|
|
3628
|
+
export declare function declaredTerrains(tileset: Tileset, names: readonly TerrainName[], declared: readonly DeclaredTerrain[]): TerrainType[];
|
|
3629
|
+
/**
|
|
3630
|
+
* What a tile is to the game, as a string: its CV5 group's flag word and its megatile's sixteen
|
|
3631
|
+
* VF4 words. Two tiles with the same key walk, build, block sight and stand at the same height
|
|
3632
|
+
* alike; the Tile palette's lists also take it as half of "the same tile" (`tileCopies.ts`).
|
|
3633
|
+
*/
|
|
3634
|
+
export declare function kindKey(tileset: Tileset, tile: number): string;
|
|
3635
|
+
/**
|
|
3636
|
+
* Where the groups a data set adds to the game's begin, on a tileset of `groups` groups with ERA
|
|
3637
|
+
* index `era`, or null when it adds none: when the table is longer than any of the game's
|
|
3638
|
+
* (Remastered's is the longer), the groups past the 1.16 table's end. A mod's table is laid over
|
|
3639
|
+
* 1.16's and goes on from its end (Cosmonarchy's Badlands: 1,665 groups to 4,094, every added
|
|
3640
|
+
* one untyped); a mod made over Remastered's table would count Remastered's own additions among
|
|
3641
|
+
* its groups too, which no file says otherwise.
|
|
3642
|
+
*/
|
|
3643
|
+
export declare function addedGroupsFrom(era: number, groups: number): number | null;
|
|
2466
3644
|
export interface IscriptHeader {
|
|
2467
3645
|
id: number;
|
|
2468
3646
|
type: number;
|
|
@@ -3227,302 +4405,82 @@ export declare function pngToGrp(png: Uint8Array, palette: NamedPalette, options
|
|
|
3227
4405
|
report: QuantiseReport;
|
|
3228
4406
|
}>;
|
|
3229
4407
|
/**
|
|
3230
|
-
*
|
|
3231
|
-
*
|
|
3232
|
-
* command line and any page share it.
|
|
3233
|
-
*
|
|
3234
|
-
* - **A zip**: its central directory read, the "stored" and "deflate" members inflated with the platform's own
|
|
3235
|
-
* `DecompressionStream("deflate-raw")`. No zip64 and no encryption; such a zip is refused in words.
|
|
3236
|
-
* - **MPQDraft's self-executing MPQ** (SEMPQ): a small Windows program with the archive appended at a 512-byte boundary
|
|
3237
|
-
* after the program, where storm looks for one.
|
|
3238
|
-
* - **FireGraft's patcher**: the program, then an overlay `"PEGF"`, u32 1, u32 count, and for each plugin u32 id,
|
|
3239
|
-
* u32 size, u32 0; then the plugins' bytes, then the archive. The plugins are recorded, never run.
|
|
3240
|
-
*
|
|
3241
|
-
* Nothing of an exe is run or kept but its archive.
|
|
4408
|
+
* A path as the game names it: backslashes, lower case, no leading backslash (`arr\units.dat`), as this library has
|
|
4409
|
+
* always given it. (`@scm-js/mod`'s own `gameName` keeps a leading backslash: storm finds a member by its stored name.)
|
|
3242
4410
|
*/
|
|
3243
|
-
/** The game's own top folders: a mod's files sit under these. */
|
|
3244
|
-
export declare const GAME_FOLDERS: string[];
|
|
3245
|
-
/** A path as the game names it: backslashes, lower case (`arr\units.dat`). Two paths are one file when these agree. */
|
|
3246
4411
|
export declare const gameName: (path: string) => string;
|
|
3247
|
-
/**
|
|
3248
|
-
* Files an operating system or its file manager leaves in folders, and into the archives and zips made of them: never
|
|
3249
|
-
* the game's, so never a mod's. Told by name alone, any case — the last part of a path, or a folder on the way to it:
|
|
3250
|
-
*
|
|
3251
|
-
* - `desktop.ini`: Windows Explorer's settings for a folder (its view, its icon);
|
|
3252
|
-
* - `Thumbs.db`, `ehthumbs.db`, `ehthumbs_vista.db`: Explorer's and Media Center's caches of thumbnails;
|
|
3253
|
-
* - `.DS_Store`: the macOS Finder's settings for a folder; `Icon\r`: a folder's own icon there;
|
|
3254
|
-
* - `._<name>`: the AppleDouble half of a file, which macOS writes beside it on a disk that is not its own and into
|
|
3255
|
-
* every zip it makes; `__MACOSX/`: the folder those zips keep them in;
|
|
3256
|
-
* - `.directory`: KDE's settings for a folder.
|
|
3257
|
-
*
|
|
3258
|
-
* A mod's hash has no line for one (`hash.ts`), and what reads a mod leaves them out of its files. Why it matters:
|
|
3259
|
-
* the same folder is not handed over alike by every route. A browser's folder handle (the folder picker, a dropped
|
|
3260
|
-
* folder read through its handle) never hands over `desktop.ini` or `Thumbs.db`: Chromium's
|
|
3261
|
-
* `FileSystemAccessManagerImpl::IsSafePathComponent` refuses the names `base::IsReservedNameOnWindows` lists, on every
|
|
3262
|
-
* system. A drop read through its entries, an `<input webkitdirectory>` and the command line hand them over. With
|
|
3263
|
-
* these files in the hash a mod was named by how its folder had been read.
|
|
3264
|
-
*
|
|
3265
|
-
* Only names that are certain never to be a game file are here. A handle hides more than these (`.lnk`, `.url` and
|
|
3266
|
-
* `.scf` files, Windows' device names such as `aux.wav`, names that begin or end with a space, a dot or `~`, and on
|
|
3267
|
-
* Windows, by Chromium's table of file types, every `.ini`, `.cfg`, `.dll` and `.manifest`): those may be a mod's own
|
|
3268
|
-
* files, so they keep their lines, and a route that cannot read one has a mod short of that file and says so with
|
|
3269
|
-
* another hash.
|
|
3270
|
-
*/
|
|
3271
|
-
export declare const SYSTEM_FILES: {
|
|
3272
|
-
/** File names, lower case. */
|
|
3273
|
-
readonly names: readonly [
|
|
3274
|
-
"desktop.ini",
|
|
3275
|
-
"thumbs.db",
|
|
3276
|
-
"ehthumbs.db",
|
|
3277
|
-
"ehthumbs_vista.db",
|
|
3278
|
-
".ds_store",
|
|
3279
|
-
"icon\r",
|
|
3280
|
-
".directory"
|
|
3281
|
-
];
|
|
3282
|
-
/** What a file name starts with. */
|
|
3283
|
-
readonly prefixes: readonly [
|
|
3284
|
-
"._"
|
|
3285
|
-
];
|
|
3286
|
-
/** Folder names, lower case: everything under one. */
|
|
3287
|
-
readonly folders: readonly [
|
|
3288
|
-
"__macosx"
|
|
3289
|
-
];
|
|
3290
|
-
};
|
|
3291
|
-
/** Whether a path (either slash, any case) is one of `SYSTEM_FILES`: by its file name, or by a folder it is under. */
|
|
3292
|
-
export declare function isSystemFile(path: string): boolean;
|
|
3293
|
-
/** The game's own archives, by file name (lower case): what a 1.16.1 installation holds beside its program. */
|
|
3294
|
-
export declare const GAME_ARCHIVES: readonly [
|
|
3295
|
-
"stardat.mpq",
|
|
3296
|
-
"broodat.mpq",
|
|
3297
|
-
"patch_rt.mpq",
|
|
3298
|
-
"starcraft.mpq",
|
|
3299
|
-
"broodwar.mpq"
|
|
3300
|
-
];
|
|
3301
|
-
/**
|
|
3302
|
-
* The files among `paths` (forward slashes) that are a copy of the game's own and so no part of a mod: in every folder
|
|
3303
|
-
* that holds a `StarDat.mpq`, that folder's `GAME_ARCHIVES` and every file under its `Maps` folder.
|
|
3304
|
-
*
|
|
3305
|
-
* A copy of the game in what was handed over is not the mod. A person hands over a folder that holds the mod's release
|
|
3306
|
-
* and, beside it, the whole game the mod runs on (Cosmonarchy's download: `Release/` and `Starcraft/`); laid as layers
|
|
3307
|
-
* of the mod, the game's archives became "the mod's" files, and in Windows' folder order `StarDat.mpq` came last and
|
|
3308
|
-
* carried original StarCraft's tables and iscript over Brood War's. A copy's `Maps` folder is the person's maps folder:
|
|
3309
|
-
nothing under it is a mod's (Cosmonarchy's copy keeps campaigns at `Maps/CMBW-Root/CMBW-maps/campaign/…`, and
|
|
3310
|
-
`campaign` is one of the game's folders, so they were taken for a mod's root). Apply it to each list a walk is given (a folder's
|
|
3311
|
-
* files, a zip's members), never to a single file the person names: some old mods ship as a replaced `patch_rt.mpq`.
|
|
3312
|
-
* The same rule is in the play page and the Mod Editor plugin: change them together.
|
|
3313
|
-
*/
|
|
3314
|
-
export declare function gameCopyFiles(paths: readonly string[]): Set<string>;
|
|
3315
|
-
/**
|
|
3316
|
-
* The folder of a set of paths the game's paths start in: the one that holds `arr/`, else the one holding the most
|
|
3317
|
-
* files under the game's folders, the shallower on a tie; "" is the root. Paths use forward slashes. At any depth, as
|
|
3318
|
-
* the play page looks (a zip's `Mod 1.2/mpq/arr/…`); a game folder's name deeper in a root (`unit/terran/unit/`)
|
|
3319
|
-
* scores fewer files than the root itself, so it does not win.
|
|
3320
|
-
*/
|
|
3321
|
-
export declare function modRoot(paths: readonly string[]): string;
|
|
3322
|
-
/** Where a Windows program's own bytes end (after its last section), or null when the bytes are no program. */
|
|
3323
|
-
export declare function programEnd(b: Uint8Array): number | null;
|
|
3324
|
-
export interface ExeArchive {
|
|
3325
|
-
/** The archive, from its header on. */
|
|
3326
|
-
archive: Uint8Array;
|
|
3327
|
-
/** Where in the exe it starts. */
|
|
3328
|
-
at: number;
|
|
3329
|
-
kind: "sempq" | "firegraft";
|
|
3330
|
-
/** FireGraft's plugins in the overlay, by id and size (never run, not kept). */
|
|
3331
|
-
plugins: {
|
|
3332
|
-
id: number;
|
|
3333
|
-
size: number;
|
|
3334
|
-
}[];
|
|
3335
|
-
}
|
|
3336
|
-
/** The mod archive inside a self-executing exe, or null when the exe holds none (a program only). */
|
|
3337
|
-
export declare function exeArchive(b: Uint8Array): ExeArchive | null;
|
|
3338
|
-
/** An MPQ from its first byte (a mod's `.mpq`). */
|
|
3339
|
-
export declare const isMpq: (b: Uint8Array) => boolean;
|
|
3340
|
-
/** A zip, by its first member's local header (or an empty zip's end record). */
|
|
3341
|
-
export declare const isZip: (b: Uint8Array) => boolean;
|
|
3342
|
-
/** A Windows program. */
|
|
3343
|
-
export declare const isExe: (b: Uint8Array) => boolean;
|
|
3344
|
-
export interface ZipMember {
|
|
3345
|
-
/** The member's path in the zip, forward slashes. */
|
|
3346
|
-
path: string;
|
|
3347
|
-
size: number;
|
|
3348
|
-
read(): Promise<Uint8Array>;
|
|
3349
|
-
}
|
|
3350
|
-
export declare class ModSourceError extends Error {
|
|
3351
|
-
}
|
|
3352
|
-
/** The files of a zip (folders left out), read lazily. */
|
|
3353
|
-
export declare function readZip(b: Uint8Array): ZipMember[];
|
|
3354
|
-
/**
|
|
3355
|
-
* The hash of game files alone, by the mod hash's rule (`hash.ts`): a line `name<TAB>sha256` a file (the game's name,
|
|
3356
|
-
* lower case with backslashes), sorted by name, joined with newlines, hashed again; the first sixteen hex digits. An
|
|
3357
|
-
* operating system's files (`isSystemFile`) have no line. A mod's hash also has lines for its plugins and FireGraft
|
|
3358
|
-
* project: `modHash` / `modHashOfDigests` in `hash.ts`; for a mod without either the two agree.
|
|
3359
|
-
*/
|
|
3360
|
-
export declare function dataSetHash(files: readonly {
|
|
3361
|
-
name: string;
|
|
3362
|
-
bytes: Uint8Array;
|
|
3363
|
-
}[]): Promise<string>;
|
|
3364
|
-
/** One file's SHA-256 in hex, as `dataSetHash` takes it: for a caller that hashes a file at a time and lets the bytes go. */
|
|
3365
|
-
export declare const fileDigest: (bytes: Uint8Array) => Promise<string>;
|
|
3366
|
-
/** `dataSetHash` from each file's `fileDigest` rather than its bytes: the same rule, the same hash. */
|
|
3367
|
-
export declare function dataSetHashOfDigests(files: readonly {
|
|
3368
|
-
name: string;
|
|
3369
|
-
sha256: string;
|
|
3370
|
-
}[]): Promise<string>;
|
|
3371
|
-
/** A plugin a mod carries: MPQDraft's `.qdp`, Chaoslauncher's `.bwl`. */
|
|
3372
|
-
export declare const isPluginFile: (name: string) => boolean;
|
|
3373
|
-
/** FireGraft's project, the one FireGraft file the hash has a line for. */
|
|
3374
|
-
export declare const isFiregraftProject: (name: string) => boolean;
|
|
3375
|
-
/** A file of a mod's code rather than the game's: a plugin, FireGraft's project or database. */
|
|
3376
|
-
export declare const isModCode: (name: string) => boolean;
|
|
3377
|
-
/** A plugin's line: `plugins\<file name>`, lower case. */
|
|
3378
|
-
export declare const pluginLine: (name: string, sha256: string) => string;
|
|
3379
|
-
/** The FireGraft project's line: `<file name>.fgp`, lower case. */
|
|
3380
|
-
export declare const firegraftLine: (name: string, sha256: string) => string;
|
|
3381
|
-
/** A game file's line: its game name. */
|
|
3382
|
-
export declare const gameLine: (name: string, sha256: string) => string;
|
|
3383
|
-
/** Whether a line `name<TAB>sha256` is of an operating system's file (`isSystemFile`), which the hash has no line for. */
|
|
3384
|
-
export declare const isSystemLine: (line: string) => boolean;
|
|
3385
|
-
/**
|
|
3386
|
-
* The hash of lines `name<TAB>sha256` in any order: sorted by name, joined with "\n", SHA-256, sixteen hex digits. A
|
|
3387
|
-
* line of an operating system's file (`isSystemLine`) is dropped first.
|
|
3388
|
-
*/
|
|
3389
|
-
export declare function hashLines(lines: readonly string[]): Promise<string>;
|
|
3390
|
-
/**
|
|
3391
|
-
* `hashLines` as it was until 2026-11-09: every line given, an operating system's files among them. For matching a
|
|
3392
|
-
* hash made then (a replay's tag, a mod kept in a browser), never for naming a mod now.
|
|
3393
|
-
*/
|
|
3394
|
-
export declare function hashLinesAsWere(lines: readonly string[]): Promise<string>;
|
|
3395
|
-
/** A file by its name and its bytes' SHA-256 (`fileDigest`). */
|
|
4412
|
+
/** @deprecated A file by name and SHA-256: give `readMod` the mod's files and read `identity` instead. */
|
|
3396
4413
|
export interface Digest {
|
|
3397
4414
|
name: string;
|
|
3398
4415
|
sha256: string;
|
|
3399
4416
|
}
|
|
3400
|
-
/** What
|
|
4417
|
+
/** @deprecated What `modHashOfDigests` takes: use `readMod` and its `identity`. */
|
|
3401
4418
|
export interface ModHashInput {
|
|
3402
4419
|
files: readonly Digest[];
|
|
3403
|
-
/** Plugins carried as files (
|
|
4420
|
+
/** Plugins carried as files (`.qdp`, `.bwl`). */
|
|
3404
4421
|
plugins?: readonly Digest[];
|
|
3405
4422
|
/** FireGraft's files; only the project (`.fgp`) has a line. */
|
|
3406
4423
|
firegraft?: readonly Digest[];
|
|
3407
4424
|
}
|
|
4425
|
+
/** @deprecated What `modHashOfDigests` gives: use `ModDescription.identity`. */
|
|
3408
4426
|
export interface ModHash {
|
|
3409
|
-
/** The mod's hash: every line. */
|
|
3410
4427
|
hash: string;
|
|
3411
|
-
/** The hash without the plugins' lines: what a page that does not run them presents. */
|
|
3412
4428
|
withoutPlugins: string;
|
|
3413
|
-
/** The lines without the plugins' (sorted)
|
|
4429
|
+
/** The lines without the plugins' (sorted). */
|
|
3414
4430
|
lines: string[];
|
|
3415
4431
|
/** The plugins' lines (sorted). */
|
|
3416
4432
|
pluginLines: string[];
|
|
3417
|
-
/**
|
|
3418
|
-
* There when an operating system's files were among what was given (`isSystemFile`): the mod's hashes as they were
|
|
3419
|
-
* while those files had lines (`hashLinesAsWere`), and the names left out. Matched as an older form, never presented.
|
|
3420
|
-
*/
|
|
4433
|
+
/** There when an operating system's files were among the digests: the hashes while they had lines, and their names. */
|
|
3421
4434
|
older?: {
|
|
3422
4435
|
hash: string;
|
|
3423
4436
|
withoutPlugins: string;
|
|
3424
4437
|
left: string[];
|
|
3425
4438
|
};
|
|
3426
4439
|
}
|
|
4440
|
+
/** A module of the mod's code's line, `plugins\<file name>`, lower case: from a path too (its file name is taken). */
|
|
4441
|
+
export declare const pluginLine: (name: string, sha256: string) => string;
|
|
4442
|
+
/** The FireGraft project's line, `<file name>`, lower case: from a path too (its file name is taken). */
|
|
4443
|
+
export declare const firegraftLine: (name: string, sha256: string) => string;
|
|
4444
|
+
/** @deprecated Whether a file is FireGraft's project: `/\.fgp$/i`. */
|
|
4445
|
+
export declare const isFiregraftProject: (name: string) => boolean;
|
|
4446
|
+
/** @deprecated A game file's line, `name<TAB>sha256` by its game name: `ModDescription.identity.lines` holds them. */
|
|
4447
|
+
export declare const gameLine: (name: string, sha256: string) => string;
|
|
3427
4448
|
/**
|
|
3428
|
-
*
|
|
3429
|
-
*
|
|
3430
|
-
*
|
|
4449
|
+
* @deprecated Use `readMod` and its `identity`, which also has lines for a patcher's own plugins and the libraries a
|
|
4450
|
+
* mod's plugins load. The hash of these files by `@scm-js/mod`'s lines: game files by game name (the last given wins),
|
|
4451
|
+
* plugins (`.qdp`, `.bwl`) and the FireGraft project once by file name (the first wins); an operating system's files
|
|
4452
|
+
* have no line, and `older` says what the hashes were with them.
|
|
3431
4453
|
*/
|
|
3432
4454
|
export declare function modHashOfDigests(input: ModHashInput): Promise<ModHash>;
|
|
3433
|
-
|
|
4455
|
+
export type Named = {
|
|
4456
|
+
name: string;
|
|
4457
|
+
bytes: Uint8Array;
|
|
4458
|
+
};
|
|
4459
|
+
/** @deprecated `modHashOfDigests` from the files' bytes: use `readMod` and its `identity`. */
|
|
3434
4460
|
export declare function modHash(input: {
|
|
3435
|
-
files: readonly
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
}[];
|
|
3439
|
-
plugins?: readonly {
|
|
3440
|
-
name: string;
|
|
3441
|
-
bytes: Uint8Array;
|
|
3442
|
-
}[];
|
|
3443
|
-
firegraft?: readonly {
|
|
3444
|
-
name: string;
|
|
3445
|
-
bytes: Uint8Array;
|
|
3446
|
-
}[];
|
|
4461
|
+
files: readonly Named[];
|
|
4462
|
+
plugins?: readonly Named[];
|
|
4463
|
+
firegraft?: readonly Named[];
|
|
3447
4464
|
}): Promise<ModHash>;
|
|
4465
|
+
/** @deprecated The hash of game files alone (no code): `hashLines` over their lines, or `readMod(…).identity` for a mod. */
|
|
4466
|
+
export declare function dataSetHashOfDigests(files: readonly Digest[]): Promise<string>;
|
|
4467
|
+
/** @deprecated `dataSetHashOfDigests` from the files' bytes. */
|
|
4468
|
+
export declare function dataSetHash(files: readonly Named[]): Promise<string>;
|
|
3448
4469
|
/**
|
|
3449
|
-
* The
|
|
3450
|
-
* `
|
|
3451
|
-
* tables in both layouts), and every path the archive's own `arr\images.tbl`, `sfxdata.tbl` and `portdata.tbl` name.
|
|
3452
|
-
* `read` answers a member of the archive, or null. (The play page also reads those three tables from the person's own
|
|
3453
|
-
* game; this does not, so the set never depends on a copy.)
|
|
3454
|
-
*/
|
|
3455
|
-
export declare function probeNames(read: (name: string) => Uint8Array | null): string[];
|
|
3456
|
-
/** A race a data set adds to the game's own. */
|
|
3457
|
-
export interface DataSetRace {
|
|
3458
|
-
/** The race byte: 8–255. (0–7 are the game's and cannot be declared.) */
|
|
3459
|
-
id: number;
|
|
3460
|
-
/** What it is called, 40 characters at most, trimmed, not empty. */
|
|
3461
|
-
name: string;
|
|
3462
|
-
/** The lower-case letter its per-race files go by (`game\<letter>console.pcx`, `rez\statbtn<letter>.bin`), when it has them. */
|
|
3463
|
-
letter?: string;
|
|
3464
|
-
/** The game's race it plays as, where only the game's three are known: 0, 1 or 2. Absent: not declared. */
|
|
3465
|
-
like?: 0 | 1 | 2;
|
|
3466
|
-
}
|
|
3467
|
-
/** The first race byte a data set may declare; 0–7 are the game's. */
|
|
3468
|
-
export declare const FIRST_DATASET_RACE = 8;
|
|
3469
|
-
/** The longest name a declared race may have. */
|
|
3470
|
-
export declare const RACE_NAME_MAX = 40;
|
|
3471
|
-
/**
|
|
3472
|
-
* The game's own eight races by their byte (0 Zerg … 7 Inactive), English as the editor's tables have them (shown
|
|
3473
|
-
* through `translate`).
|
|
4470
|
+
* The archive in a self-executing exe, as `@scm-js/mod` reads it, with the two fields this library gave before:
|
|
4471
|
+
* `kind` (`form` in the package's words) and `archive` (the exe's bytes from the archive's header on).
|
|
3474
4472
|
*/
|
|
3475
|
-
export
|
|
3476
|
-
/**
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
export declare function normalizeRaces(value: unknown): DataSetRace[];
|
|
3484
|
-
/** Whether two tables say the same (after `normalizeRaces`): the same ids, names, letters and `like`s, in order. */
|
|
3485
|
-
export declare function sameRaces(a: readonly DataSetRace[], b: readonly DataSetRace[]): boolean;
|
|
3486
|
-
/**
|
|
3487
|
-
* A race by its byte: the game's own name (English, as `playerRaceLabel` gives it), else the name `races` declares,
|
|
3488
|
-
* else `Race {id}`. With no table it is `playerRaceLabel`.
|
|
3489
|
-
*/
|
|
3490
|
-
export declare function raceLabel(id: number, races?: readonly DataSetRace[]): string;
|
|
3491
|
-
/** The races to offer for a choice: the game's eight in StarEdit's order, then the declared ones by id. */
|
|
3492
|
-
export declare function raceChoices(races?: readonly DataSetRace[]): {
|
|
3493
|
-
value: number;
|
|
3494
|
-
label: string;
|
|
3495
|
-
}[];
|
|
3496
|
-
/** How many entries the game's own `rez\network.tbl` has (1.16.1's, the same in Remastered): a mod's past it are its own. */
|
|
3497
|
-
export declare const GAME_NETWORK_TBL_ENTRIES = 168;
|
|
3498
|
-
/** What a mod's files suggest about the races it adds: hints for a person naming them, never names in themselves. */
|
|
3499
|
-
export interface RaceCandidates {
|
|
3500
|
-
/** Strings the mod's `rez\network.tbl` has past the game's own table, with their index there (0-based). */
|
|
3501
|
-
names: {
|
|
3502
|
-
index: number;
|
|
3503
|
-
name: string;
|
|
3504
|
-
}[];
|
|
3505
|
-
/** Letters other than z, t, p and n that have `game\<x>console.pcx` or `rez\statbtn<x>.bin`, sorted. */
|
|
3506
|
-
letters: string[];
|
|
4473
|
+
export interface ExeArchive extends PackageExeArchive {
|
|
4474
|
+
/** @deprecated Use `form`: `"firegraft"` for FireGraft's patcher, `"sempq"` for any other exe with an archive. */
|
|
4475
|
+
kind: "sempq" | "firegraft";
|
|
4476
|
+
/**
|
|
4477
|
+
* @deprecated Open `bytes` at `at` (`Archive.open(bytes, { offset: at })`): an archive whose tables lie before its
|
|
4478
|
+
* header cannot be opened from this slice.
|
|
4479
|
+
*/
|
|
4480
|
+
archive: Uint8Array;
|
|
3507
4481
|
}
|
|
3508
|
-
/**
|
|
3509
|
-
|
|
3510
|
-
* none); `gameNetwork` the game's own, from a copy of the game (its length is `GAME_NETWORK_TBL_ENTRIES` without one);
|
|
3511
|
-
* `paths` the mod's files by any spelling of their game names. A race's name must never be filled in from these alone.
|
|
3512
|
-
*/
|
|
3513
|
-
export declare function raceCandidates(files: {
|
|
3514
|
-
network?: Uint8Array | null;
|
|
3515
|
-
gameNetwork?: Uint8Array | null;
|
|
3516
|
-
paths: Iterable<string>;
|
|
3517
|
-
}): RaceCandidates;
|
|
3518
|
-
/** Whether there is anything in `RaceCandidates` to offer. */
|
|
3519
|
-
export declare const hasRaceCandidates: (c: RaceCandidates) => boolean;
|
|
3520
|
-
/**
|
|
3521
|
-
* Which of the game's three races a player plays as, from the units they build or own: the Zerg, Terran or Protoss
|
|
3522
|
-
* group flag (units.dat's StarEdit group flags, bits 0–2) most of `unitIds` carry. Null when none carries one, when two
|
|
3523
|
-
* are carried by as many, or with no units: unknown, not guessed. A unit counts once per flag it carries.
|
|
3524
|
-
*/
|
|
3525
|
-
export declare function racePlaysAs(unitIds: Iterable<number>, units: Pick<UnitsDat, "groupFlags">): 0 | 1 | 2 | null;
|
|
4482
|
+
/** `@scm-js/mod`'s `exeArchive`, with `kind` and `archive` beside its own fields. Throws its `PatcherError`. */
|
|
4483
|
+
export declare function exeArchive(b: Uint8Array): ExeArchive | null;
|
|
3526
4484
|
/** The manifest's file name, at the folder's root. */
|
|
3527
4485
|
export declare const MOD_MANIFEST = "mod.json";
|
|
3528
4486
|
/** The folder format's version, `scmjs` in the manifest. */
|
|
@@ -3815,6 +4773,170 @@ export interface DiffSide {
|
|
|
3815
4773
|
names: string[];
|
|
3816
4774
|
}
|
|
3817
4775
|
export declare function diffMods(a: DiffSide, b: DiffSide): Promise<ModChange[]>;
|
|
4776
|
+
/** The first race byte a data set may declare; 0–7 are the game's. */
|
|
4777
|
+
export declare const FIRST_DATASET_RACE = 8;
|
|
4778
|
+
/**
|
|
4779
|
+
* The game's own eight races by their byte (0 Zerg … 7 Inactive), English as the editor's tables have them (shown
|
|
4780
|
+
* through `translate`).
|
|
4781
|
+
*/
|
|
4782
|
+
export declare const GAME_RACE_NAMES: readonly string[];
|
|
4783
|
+
/** Whether two tables say the same (after `normalizeRaces`): the same ids, names, letters and `like`s, in order. */
|
|
4784
|
+
export declare function sameRaces(a: readonly DataSetRace[], b: readonly DataSetRace[]): boolean;
|
|
4785
|
+
/**
|
|
4786
|
+
* A race by its byte: the game's own name (English, as `playerRaceLabel` gives it), else the name `races` declares,
|
|
4787
|
+
* else `Race {id}`. With no table it is `playerRaceLabel`.
|
|
4788
|
+
*/
|
|
4789
|
+
export declare function raceLabel(id: number, races?: readonly DataSetRace[]): string;
|
|
4790
|
+
/** The races to offer for a choice: the game's eight in StarEdit's order, then the declared ones by id. */
|
|
4791
|
+
export declare function raceChoices(races?: readonly DataSetRace[]): {
|
|
4792
|
+
value: number;
|
|
4793
|
+
label: string;
|
|
4794
|
+
}[];
|
|
4795
|
+
/** Whether there is anything in `RaceCandidates` to offer. */
|
|
4796
|
+
export declare const hasRaceCandidates: (c: RaceCandidates) => boolean;
|
|
4797
|
+
/**
|
|
4798
|
+
* Which of the game's three races a player plays as, from the units they build or own: the Zerg, Terran or Protoss
|
|
4799
|
+
* group flag (units.dat's StarEdit group flags, bits 0–2) most of `unitIds` carry. Null when none carries one, when two
|
|
4800
|
+
* are carried by as many, or with no units: unknown, not guessed. A unit counts once per flag it carries.
|
|
4801
|
+
*/
|
|
4802
|
+
export declare function racePlaysAs(unitIds: Iterable<number>, units: Pick<UnitsDat, "groupFlags">): 0 | 1 | 2 | null;
|
|
4803
|
+
export declare const TERRAIN_FILE = "terrain.json";
|
|
4804
|
+
export declare const TERRAIN_FORMAT = 1;
|
|
4805
|
+
/** The bounds a row must keep to; past them the row (or the rest of a list) is dropped. */
|
|
4806
|
+
export declare const TERRAIN_LIMITS: {
|
|
4807
|
+
readonly nameLength: 60;
|
|
4808
|
+
readonly categoryLength: 40;
|
|
4809
|
+
readonly terrains: 2048;
|
|
4810
|
+
readonly pieces: 20000;
|
|
4811
|
+
readonly pieceSide: 64;
|
|
4812
|
+
readonly pairs: 200000;
|
|
4813
|
+
/** A table hash: the 13–14 base-36 characters `tableHash` gives, with room. */
|
|
4814
|
+
readonly tableLength: 32;
|
|
4815
|
+
readonly borders: 2048;
|
|
4816
|
+
readonly borderShapes: 1024;
|
|
4817
|
+
readonly shapeLength: 80;
|
|
4818
|
+
readonly shapeTiles: 64;
|
|
4819
|
+
readonly copies: 256;
|
|
4820
|
+
};
|
|
4821
|
+
export interface TerrainFileTerrain {
|
|
4822
|
+
name: string;
|
|
4823
|
+
group: number;
|
|
4824
|
+
}
|
|
4825
|
+
export interface TerrainFilePiece {
|
|
4826
|
+
name?: string;
|
|
4827
|
+
category?: string;
|
|
4828
|
+
cols: number;
|
|
4829
|
+
rows: number;
|
|
4830
|
+
tiles: number[];
|
|
4831
|
+
}
|
|
4832
|
+
export interface TerrainFileBorrow {
|
|
4833
|
+
source: string;
|
|
4834
|
+
pairs: [
|
|
4835
|
+
number,
|
|
4836
|
+
number
|
|
4837
|
+
][];
|
|
4838
|
+
/** Source tiles whose tile here is only the nearest picture (no copy): what the editor's scan calls a stand-in. */
|
|
4839
|
+
standIns?: number[];
|
|
4840
|
+
}
|
|
4841
|
+
/** A drawn border: the borrowed terrain (`terrain`, its index in `source`) on this tileset's ground (`ground`, its index here). */
|
|
4842
|
+
export interface TerrainFileBorder {
|
|
4843
|
+
source: string;
|
|
4844
|
+
terrain: number;
|
|
4845
|
+
ground: number;
|
|
4846
|
+
/** Shape → the tiles to lay there, the likeliest first. */
|
|
4847
|
+
shapes: Record<string, number[]>;
|
|
4848
|
+
}
|
|
4849
|
+
/** A block of copied terrain: the terrain copied (`terrain`, its id here) at the copy's `height`, its pieces drawn to meet `ground`. */
|
|
4850
|
+
export interface TerrainFileCopy {
|
|
4851
|
+
terrain: number;
|
|
4852
|
+
height: number;
|
|
4853
|
+
ground: {
|
|
4854
|
+
terrain: number;
|
|
4855
|
+
} | {
|
|
4856
|
+
pair: number;
|
|
4857
|
+
};
|
|
4858
|
+
/** A piece of the terrain's edge set (`group << 4 | slot`) → the tile standing for it. */
|
|
4859
|
+
pieces: [
|
|
4860
|
+
number,
|
|
4861
|
+
number
|
|
4862
|
+
][];
|
|
4863
|
+
}
|
|
4864
|
+
export interface TerrainFileSection {
|
|
4865
|
+
table: string;
|
|
4866
|
+
terrains: TerrainFileTerrain[];
|
|
4867
|
+
pieces: TerrainFilePiece[];
|
|
4868
|
+
borrow: TerrainFileBorrow[];
|
|
4869
|
+
borders: TerrainFileBorder[];
|
|
4870
|
+
copies: TerrainFileCopy[];
|
|
4871
|
+
/** Keys this reader does not know, kept as they were. */
|
|
4872
|
+
extra: Record<string, unknown>;
|
|
4873
|
+
}
|
|
4874
|
+
export interface TerrainFile {
|
|
4875
|
+
format: number;
|
|
4876
|
+
/** By tileset id (`badlands`, `install`, …). */
|
|
4877
|
+
tilesets: Record<string, TerrainFileSection>;
|
|
4878
|
+
/** Keys this reader does not know, kept as they were (an unknown tileset name included). */
|
|
4879
|
+
extra: Record<string, unknown>;
|
|
4880
|
+
}
|
|
4881
|
+
/** Why a row was left out. */
|
|
4882
|
+
export type TerrainDropReason = "not-json" | "not-an-object" | "format" | "tileset" | "table" | "not-a-list" | "too-many" | "name" | "group" | "size" | "tiles" | "empty" | "source" | "pair" | "duplicate" | "terrain";
|
|
4883
|
+
export interface TerrainDrop {
|
|
4884
|
+
/** Where, as a path in the file: `tilesets.badlands.pieces[3]`. */
|
|
4885
|
+
at: string;
|
|
4886
|
+
reason: TerrainDropReason;
|
|
4887
|
+
}
|
|
4888
|
+
export interface TerrainFileRead {
|
|
4889
|
+
file: TerrainFile;
|
|
4890
|
+
dropped: TerrainDrop[];
|
|
4891
|
+
}
|
|
4892
|
+
export declare const emptyTerrainFile: () => TerrainFile;
|
|
4893
|
+
export declare const emptyTerrainSection: (table: string) => TerrainFileSection;
|
|
4894
|
+
/** Read a terrain file from its text (or an already parsed value). Never throws. */
|
|
4895
|
+
export declare function readTerrainFile(input: string | unknown): TerrainFileRead;
|
|
4896
|
+
/**
|
|
4897
|
+
* What of a section the loaded table cannot use: a terrain whose group is no pair of flat ground with pictures, a piece
|
|
4898
|
+
* with a tile past the table or on a slot with no picture, a borrow pair whose tile is past the host's table. For
|
|
4899
|
+
* `mod check`; the editor leaves such rows out where it lists them, as it does a plugin's.
|
|
4900
|
+
*/
|
|
4901
|
+
export declare function sectionAgainstTable(section: TerrainFileSection, id: string, table: {
|
|
4902
|
+
groups: number;
|
|
4903
|
+
hasPicture(tile: number): boolean;
|
|
4904
|
+
}): TerrainDrop[];
|
|
4905
|
+
/** The file with `id`'s section replaced (or removed for null); every other section and unknown key kept. */
|
|
4906
|
+
export declare function withTerrainSection(file: TerrainFile, id: string, section: TerrainFileSection | null): TerrainFile;
|
|
4907
|
+
/**
|
|
4908
|
+
* The file as text: known keys first, in a fixed order, each row on one line (a file of thousands of pieces stays
|
|
4909
|
+
* readable and diffs by row), then the unknown keys as they were read.
|
|
4910
|
+
*/
|
|
4911
|
+
export declare function writeTerrainFile(file: TerrainFile): string;
|
|
4912
|
+
/** Counts per tileset, for `mod info` and the editor's notes. */
|
|
4913
|
+
export declare function terrainFileCounts(file: TerrainFile): Record<string, {
|
|
4914
|
+
terrains: number;
|
|
4915
|
+
pieces: number;
|
|
4916
|
+
borrow: {
|
|
4917
|
+
source: string;
|
|
4918
|
+
pairs: number;
|
|
4919
|
+
}[];
|
|
4920
|
+
borders: {
|
|
4921
|
+
source: string;
|
|
4922
|
+
terrain: number;
|
|
4923
|
+
ground: number;
|
|
4924
|
+
shapes: number;
|
|
4925
|
+
}[];
|
|
4926
|
+
copies: {
|
|
4927
|
+
terrain: number;
|
|
4928
|
+
height: number;
|
|
4929
|
+
pieces: number;
|
|
4930
|
+
}[];
|
|
4931
|
+
}>;
|
|
4932
|
+
/**
|
|
4933
|
+
* Whether a `terrain.json` at `path` (forward slashes) is the mod's: by `mod.json`'s rule (`@scm-js/mod`'s
|
|
4934
|
+
* `isModJsonPath`) — in the folder everything given is in (`top`; "" for none), or one folder down from it, never in one
|
|
4935
|
+
* of the game's folders. Of several, the caller takes the shallowest.
|
|
4936
|
+
*/
|
|
4937
|
+
export declare function isTerrainFilePath(path: string, top: string, gameFolders?: readonly string[]): boolean;
|
|
4938
|
+
/** Of the paths given, the mod's `terrain.json` (the shallowest by `isTerrainFilePath`), or null. */
|
|
4939
|
+
export declare function terrainFileOf(paths: readonly string[], top: string, gameFolders?: readonly string[]): string | null;
|
|
3818
4940
|
/** Unit type catalogue: StarEdit names by units.dat id, and the palette's grouping of them. */
|
|
3819
4941
|
export type RaceKey = "terran" | "zerg" | "protoss" | "neutral";
|
|
3820
4942
|
/** StarEdit's display names, indexed by units.dat id (0–227). */
|
|
@@ -3909,4 +5031,43 @@ export declare function validateManifest(raw: unknown, where: string): PluginMan
|
|
|
3909
5031
|
*/
|
|
3910
5032
|
export declare function resolveIcon(icon: string | undefined, base: string | null): PluginIcon | null;
|
|
3911
5033
|
|
|
5034
|
+
export {
|
|
5035
|
+
DataSetRace,
|
|
5036
|
+
GAME_ARCHIVES,
|
|
5037
|
+
GAME_FOLDERS,
|
|
5038
|
+
GAME_NETWORK_TBL_ENTRIES,
|
|
5039
|
+
Identity,
|
|
5040
|
+
MOD_MESSAGES,
|
|
5041
|
+
ModDescription,
|
|
5042
|
+
ModFiles,
|
|
5043
|
+
ModMessage,
|
|
5044
|
+
ModSourceError,
|
|
5045
|
+
PatcherError,
|
|
5046
|
+
PatcherPlugin,
|
|
5047
|
+
RACE_NAME_MAX,
|
|
5048
|
+
RaceCandidates,
|
|
5049
|
+
SYSTEM_FILES,
|
|
5050
|
+
ZipMember,
|
|
5051
|
+
fileDigest,
|
|
5052
|
+
gameCopyFiles,
|
|
5053
|
+
hashLines,
|
|
5054
|
+
hashLinesAsWere,
|
|
5055
|
+
isExe,
|
|
5056
|
+
isModCode,
|
|
5057
|
+
isMpq,
|
|
5058
|
+
isPluginFile,
|
|
5059
|
+
isSystemFile,
|
|
5060
|
+
isSystemLine,
|
|
5061
|
+
isZip,
|
|
5062
|
+
libraryName,
|
|
5063
|
+
modRoot,
|
|
5064
|
+
normalizeRaces,
|
|
5065
|
+
probeNames,
|
|
5066
|
+
programEnd,
|
|
5067
|
+
raceCandidates,
|
|
5068
|
+
readMod,
|
|
5069
|
+
readZip,
|
|
5070
|
+
renderMessage,
|
|
5071
|
+
};
|
|
5072
|
+
|
|
3912
5073
|
export {};
|