@scm-js/core 0.16.0 → 0.18.0
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 +8 -2
- package/dist/index.mjs +116 -52
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @scm-js/core 0.
|
|
2
|
+
* @scm-js/core 0.18.0 — 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
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';
|
|
@@ -849,7 +849,7 @@ export declare function formatOf(fileName: string | null | undefined): MapFormat
|
|
|
849
849
|
* that came in PKWARE-compressed and encrypted, Blizzard's own layout, goes out the same
|
|
850
850
|
* way. A new map, or one opened from a bare .chk, gets StarEdit's layout too, since it is
|
|
851
851
|
* what every build of the game reads — unless `fresh` names another compression for that
|
|
852
|
-
* case (Preferences ▸
|
|
852
|
+
* case (Preferences ▸ Files ▸ Saving), which then goes without the encryption.
|
|
853
853
|
*/
|
|
854
854
|
export declare function defaultSaveOptions(scn: Scenario, origin: MemberInfo | null, fileName: string | null, fresh?: "asOpened" | ArchiveCompression): SaveOptions;
|
|
855
855
|
/** Two ready-made settings the dialog offers as buttons. */
|
|
@@ -890,6 +890,12 @@ export interface PlannedStored {
|
|
|
890
890
|
size: number;
|
|
891
891
|
/** False for a bare .chk, the one format that cannot carry them. */
|
|
892
892
|
kept: boolean;
|
|
893
|
+
/**
|
|
894
|
+
* How many of them are left out: nothing in the map names them, and the hash table they
|
|
895
|
+
* pin has no room for them and the files the save writes (`fitStored`). The game never
|
|
896
|
+
* opens such a member; a protector puts them there to fill the table.
|
|
897
|
+
*/
|
|
898
|
+
dropped: number;
|
|
893
899
|
}
|
|
894
900
|
export interface SavePlan {
|
|
895
901
|
/** The CHK as it will be written. */
|
package/dist/index.mjs
CHANGED
|
@@ -3595,16 +3595,25 @@ var CRYPT = (() => {
|
|
|
3595
3595
|
}
|
|
3596
3596
|
return table;
|
|
3597
3597
|
})();
|
|
3598
|
-
/**
|
|
3599
|
-
function
|
|
3600
|
-
const plain = name.slice(Math.max(name.lastIndexOf("\\"), name.lastIndexOf("/")) + 1);
|
|
3598
|
+
/** MPQ's string hash of type `table` (0x100 name A, 0x200 name B, 0x300 file key), ASCII upper case, slashes as given. */
|
|
3599
|
+
function hashName(name, table) {
|
|
3601
3600
|
let s1 = 2146271213, s2 = 4008636142;
|
|
3602
|
-
for (let i = 0; i <
|
|
3603
|
-
let c =
|
|
3601
|
+
for (let i = 0; i < name.length; i++) {
|
|
3602
|
+
let c = name.charCodeAt(i) & 255;
|
|
3604
3603
|
if (c >= 97 && c <= 122) c -= 32;
|
|
3605
|
-
s1 = (CRYPT[
|
|
3604
|
+
s1 = (CRYPT[table + c] ^ s1 + s2 >>> 0) >>> 0;
|
|
3606
3605
|
s2 = c + s1 + s2 + (s2 << 5 >>> 0) + 3 >>> 0;
|
|
3607
3606
|
}
|
|
3607
|
+
return s1;
|
|
3608
|
+
}
|
|
3609
|
+
/** Whether a hash entry is the one a lookup of `name` matches: the two name hashes it compares. */
|
|
3610
|
+
function entryNames(entry, name) {
|
|
3611
|
+
const path = name.replace(/\//g, "\\");
|
|
3612
|
+
return entry.hashA === hashName(path, 256) && entry.hashB === hashName(path, 512);
|
|
3613
|
+
}
|
|
3614
|
+
/** The file key of a member: the hash of its name after the last slash, as the game takes it (ASCII upper case). */
|
|
3615
|
+
function fileKey(name, offset, size, adjusted) {
|
|
3616
|
+
const s1 = hashName(name.slice(Math.max(name.lastIndexOf("\\"), name.lastIndexOf("/")) + 1), HASH_FILE_KEY);
|
|
3608
3617
|
return adjusted ? (s1 + offset ^ size) >>> 0 : s1;
|
|
3609
3618
|
}
|
|
3610
3619
|
/** Decrypts (`encrypt` false) or encrypts the whole 32-bit words of `data` in place with `key`. */
|
|
@@ -3831,9 +3840,11 @@ var STAREDIT_SECTOR_SIZE = 4096;
|
|
|
3831
3840
|
async function saveMap(chk, options = {}) {
|
|
3832
3841
|
const method = options.compress === "zlib" || options.compress === "pkware" ? options.compress : false;
|
|
3833
3842
|
const encrypt = options.encrypt ?? false;
|
|
3834
|
-
const members = options.stored?.members.filter(hasBytes) ?? [];
|
|
3835
|
-
const stored = options.stored && members.length > 0 ? options.stored : null;
|
|
3836
3843
|
const extras = [...options.extras ?? []].filter(([name]) => normalize$2(name) !== normalize$2(SCENARIO_PATH));
|
|
3844
|
+
const fit = fitStored(options.stored ?? null, 1 + extras.length + (options.editorMembers?.size ?? 0), options.listfile ?? true, options.referenced);
|
|
3845
|
+
if (!fit) throw new Error(t("The archive has no room for the files this save writes: its hash table is filled by members the editor could not read."));
|
|
3846
|
+
const members = fit.members;
|
|
3847
|
+
const stored = options.stored && members.length > 0 ? options.stored : null;
|
|
3837
3848
|
let hashTable = stored?.hashTable ?? null;
|
|
3838
3849
|
let sectorSize = stored ? stored.sectorSize : options.sectorSize ?? 4096;
|
|
3839
3850
|
const carried = [];
|
|
@@ -3853,7 +3864,7 @@ async function saveMap(chk, options = {}) {
|
|
|
3853
3864
|
});
|
|
3854
3865
|
carriedNames.add(name);
|
|
3855
3866
|
}
|
|
3856
|
-
const listfile =
|
|
3867
|
+
const listfile = fit.listfile;
|
|
3857
3868
|
const creator = new Creator({
|
|
3858
3869
|
sectorSize,
|
|
3859
3870
|
listfile: listfile && carried.length === 0,
|
|
@@ -3893,6 +3904,49 @@ async function saveMap(chk, options = {}) {
|
|
|
3893
3904
|
return creator.writeAsync();
|
|
3894
3905
|
}
|
|
3895
3906
|
/**
|
|
3907
|
+
* Which stored members a save carries. They are laid over the hash table they came from, which
|
|
3908
|
+
* keeps its size, and every file the save writes by name (`files`: the scenario, the extras,
|
|
3909
|
+
* the editor's members; the `(listfile)` on top) needs a free slot in it. A protector sizes
|
|
3910
|
+
* the table to its files and fills it with members nothing names, so on such a map there may
|
|
3911
|
+
* be none. The game opens a member only by a name the scenario carries, and every such name
|
|
3912
|
+
* was tried when the map was opened (and is tried again here, with `referenced`), so the
|
|
3913
|
+
* members no name reaches are never opened: when they do not fit, they are left out, and with
|
|
3914
|
+
* none left the archive is written afresh with a table of its own size. A member read by name
|
|
3915
|
+
* whose bytes could not be decoded (`unreadable`) is always kept. Last, the `(listfile)` is
|
|
3916
|
+
* dropped — the game never reads it. Null when even that leaves no room.
|
|
3917
|
+
*/
|
|
3918
|
+
function fitStored(stored, files, listfile, referenced = []) {
|
|
3919
|
+
const all = stored?.members.filter(hasBytes) ?? [];
|
|
3920
|
+
if (!stored || all.length === 0) return {
|
|
3921
|
+
members: [],
|
|
3922
|
+
dropped: 0,
|
|
3923
|
+
listfile
|
|
3924
|
+
};
|
|
3925
|
+
const room = (kept) => stored.hashTable.length - kept;
|
|
3926
|
+
if (room(all.length) >= files + (listfile ? 1 : 0)) return {
|
|
3927
|
+
members: all,
|
|
3928
|
+
dropped: 0,
|
|
3929
|
+
listfile
|
|
3930
|
+
};
|
|
3931
|
+
const reached = reachedStored(stored, referenced);
|
|
3932
|
+
if (reached.length === 0 || room(reached.length) >= files + (listfile ? 1 : 0)) return {
|
|
3933
|
+
members: reached,
|
|
3934
|
+
dropped: all.length - reached.length,
|
|
3935
|
+
listfile
|
|
3936
|
+
};
|
|
3937
|
+
if (room(reached.length) >= files) return {
|
|
3938
|
+
members: reached,
|
|
3939
|
+
dropped: all.length - reached.length,
|
|
3940
|
+
listfile: false
|
|
3941
|
+
};
|
|
3942
|
+
return null;
|
|
3943
|
+
}
|
|
3944
|
+
/** The stored members a name reaches: one the scenario refers to (`referenced`), or one read by name but not decoded. */
|
|
3945
|
+
function reachedStored(stored, referenced) {
|
|
3946
|
+
const named = [...stored.unreadable, ...referenced];
|
|
3947
|
+
return stored.members.filter((m) => hasBytes(m) && named.some((name) => entryNames(m.hash, name)));
|
|
3948
|
+
}
|
|
3949
|
+
/**
|
|
3896
3950
|
* Whether a stored member has bytes to carry. A protector's block entry pointing past the
|
|
3897
3951
|
* end of the file came back from mopaq before 1.6.2 as an empty member at that offset, and
|
|
3898
3952
|
* the writer padded the archive out to reach it — a save of tens of megabytes of zeros, or a
|
|
@@ -9375,6 +9429,28 @@ var SCRIPT_FOLDER = "trigscript\\";
|
|
|
9375
9429
|
var SCRIPT_MEMBER = `${SCRIPT_FOLDER}main.ts`;
|
|
9376
9430
|
var MANIFEST_MEMBER = `${SCRIPT_FOLDER}build.json`;
|
|
9377
9431
|
/**
|
|
9432
|
+
* Every archive path the scenario itself names: the WAV table's entries and the `wav`
|
|
9433
|
+
* argument of every trigger and briefing action, plus the members the TrigScript
|
|
9434
|
+
* plugin keeps its entry file and build manifest in (the manifest then names the rest,
|
|
9435
|
+
* see `scriptMembersFromManifest`). What `readMembers` probes an archive for when its
|
|
9436
|
+
* (listfile) is gone — the one way a protected map's sounds get their names back.
|
|
9437
|
+
*/
|
|
9438
|
+
function referencedMembers(scn) {
|
|
9439
|
+
const out = /* @__PURE__ */ new Set();
|
|
9440
|
+
const add = (index) => {
|
|
9441
|
+
const path = index > 0 ? getString(scn.strings, index) : null;
|
|
9442
|
+
if (path) out.add(path);
|
|
9443
|
+
};
|
|
9444
|
+
for (const index of scn.wavs ?? []) add(index);
|
|
9445
|
+
for (const t of scn.triggers) for (const a of t.actions) for (const s of actionStrings(a, false)) if (s.kind === "wav") add(s.index);
|
|
9446
|
+
for (const t of scn.briefing) for (const a of t.actions) for (const s of actionStrings(a, true)) if (s.kind === "wav") add(s.index);
|
|
9447
|
+
return [
|
|
9448
|
+
...out,
|
|
9449
|
+
SCRIPT_MEMBER,
|
|
9450
|
+
MANIFEST_MEMBER
|
|
9451
|
+
];
|
|
9452
|
+
}
|
|
9453
|
+
/**
|
|
9378
9454
|
* The script's other files, from its build manifest: the manifest lists every file the
|
|
9379
9455
|
* block was built from, so an archive without a listfile still gives them up by name.
|
|
9380
9456
|
* Empty for anything that is not such a manifest.
|
|
@@ -9427,7 +9503,7 @@ function formatOf(fileName) {
|
|
|
9427
9503
|
* that came in PKWARE-compressed and encrypted, Blizzard's own layout, goes out the same
|
|
9428
9504
|
* way. A new map, or one opened from a bare .chk, gets StarEdit's layout too, since it is
|
|
9429
9505
|
* what every build of the game reads — unless `fresh` names another compression for that
|
|
9430
|
-
* case (Preferences ▸
|
|
9506
|
+
* case (Preferences ▸ Files ▸ Saving), which then goes without the encryption.
|
|
9431
9507
|
*/
|
|
9432
9508
|
function defaultSaveOptions(scn, origin, fileName, fresh = "asOpened") {
|
|
9433
9509
|
const format = formatOf(fileName) ?? (scn.fileVersion < 205 ? "scm" : "scx");
|
|
@@ -9555,19 +9631,22 @@ function planSave(scn, extras, options, storedMembers = null) {
|
|
|
9555
9631
|
kind: extraKind(name),
|
|
9556
9632
|
kept: options.format !== "chk" && !omitted.has(name.toLowerCase())
|
|
9557
9633
|
}));
|
|
9634
|
+
const fit = storedMembers ? fitStored(storedMembers, 1 + planned.filter((e) => e.kept).length, true, referencedMembers(scn)) : null;
|
|
9558
9635
|
const stored = storedMembers && storedMembers.members.length > 0 ? {
|
|
9559
9636
|
members: storedMembers,
|
|
9560
9637
|
count: storedMembers.members.length,
|
|
9561
9638
|
size: storedMembers.members.reduce((n, m) => n + m.data.length, 0),
|
|
9562
|
-
kept: options.format !== "chk"
|
|
9639
|
+
kept: options.format !== "chk",
|
|
9640
|
+
dropped: fit?.dropped ?? 0
|
|
9563
9641
|
} : null;
|
|
9564
9642
|
const warnings = [];
|
|
9565
9643
|
if (options.stripTerrainEditing && counts.terrainEditing > 0) warnings.push(t("Without ISOM, TILE and DD2 the isometric brush and the Doodads layer have nothing to work with when the file is opened in an editor again. The map plays the same."));
|
|
9566
9644
|
if (options.stripBookkeeping && counts.bookkeeping > 0) warnings.push(t("Switch names and the sound list are lost to editors; the game does not read them."));
|
|
9567
9645
|
if (options.stripUnknown && counts.unknown > 0) warnings.push(t("{unknown, plural, one {# section} other {# sections}} with names the format reference does not know are left out. Another editor or a protector may have put them there.", { unknown: counts.unknown }));
|
|
9568
9646
|
if (options.format === "chk" && (extras.size > 0 || stored)) warnings.push(t("A bare .chk is the scenario alone: the archive's other files are not written."));
|
|
9569
|
-
if (stored?.kept) {
|
|
9570
|
-
|
|
9647
|
+
if (stored?.kept && stored.dropped > 0) warnings.push(t("{n, plural, one {# archive member nothing in the map names is} other {# archive members nothing in the map names are}} left out: the archive's hash table has no room for them and the files this save writes. The game never opens them; a protector puts them there to fill the table.", { n: stored.dropped }));
|
|
9648
|
+
if (stored?.kept && stored.count > stored.dropped) {
|
|
9649
|
+
const n = stored.count - stored.dropped;
|
|
9571
9650
|
warnings.push(t("{n, plural, one {# archive member has no name the editor knows{decoded}; it is} other {# archive members have no name the editor knows{decoded}; they are}} written back exactly as stored, and the archive keeps its {sectorSize}-byte sectors{zlib}.", {
|
|
9572
9651
|
n,
|
|
9573
9652
|
decoded: stored.members.unreadable.length > 0 ? t(", or could not be decoded") : "",
|
|
@@ -9618,10 +9697,11 @@ async function buildMapFile(scn, extras, options, plan, stored = null) {
|
|
|
9618
9697
|
plan ??= planSave(scn, extras, options, stored);
|
|
9619
9698
|
const chk = buildChk(plan);
|
|
9620
9699
|
if (options.format === "chk") return chk;
|
|
9621
|
-
const kept = plan.stored?.kept ? plan.stored.members : null;
|
|
9700
|
+
const kept = plan.stored?.kept && plan.stored.count > plan.stored.dropped ? plan.stored.members : null;
|
|
9622
9701
|
return saveMap(chk, {
|
|
9623
9702
|
extras: keptExtras(plan, extras),
|
|
9624
9703
|
stored: kept,
|
|
9704
|
+
referenced: referencedMembers(scn),
|
|
9625
9705
|
compress: options.compression,
|
|
9626
9706
|
encrypt: options.encrypt,
|
|
9627
9707
|
sectorSize: requiredSectorSize(kept, options.compression === "zlib" ? 65536 : STAREDIT_SECTOR_SIZE)
|
|
@@ -9663,28 +9743,6 @@ function wavUsage(scn, stringIndex) {
|
|
|
9663
9743
|
scan(t("Briefing"), scn.briefing, true);
|
|
9664
9744
|
return out;
|
|
9665
9745
|
}
|
|
9666
|
-
/**
|
|
9667
|
-
* Every archive path the scenario itself names: the WAV table's entries and the `wav`
|
|
9668
|
-
* argument of every trigger and briefing action, plus the members the TrigScript
|
|
9669
|
-
* plugin keeps its entry file and build manifest in (the manifest then names the rest,
|
|
9670
|
-
* see `scriptMembersFromManifest`). What `readMembers` probes an archive for when its
|
|
9671
|
-
* (listfile) is gone — the one way a protected map's sounds get their names back.
|
|
9672
|
-
*/
|
|
9673
|
-
function referencedMembers(scn) {
|
|
9674
|
-
const out = /* @__PURE__ */ new Set();
|
|
9675
|
-
const add = (index) => {
|
|
9676
|
-
const path = index > 0 ? getString(scn.strings, index) : null;
|
|
9677
|
-
if (path) out.add(path);
|
|
9678
|
-
};
|
|
9679
|
-
for (const index of scn.wavs ?? []) add(index);
|
|
9680
|
-
for (const t of scn.triggers) for (const a of t.actions) for (const s of actionStrings(a, false)) if (s.kind === "wav") add(s.index);
|
|
9681
|
-
for (const t of scn.briefing) for (const a of t.actions) for (const s of actionStrings(a, true)) if (s.kind === "wav") add(s.index);
|
|
9682
|
-
return [
|
|
9683
|
-
...out,
|
|
9684
|
-
SCRIPT_MEMBER,
|
|
9685
|
-
MANIFEST_MEMBER
|
|
9686
|
-
];
|
|
9687
|
-
}
|
|
9688
9746
|
function readWavs(scn) {
|
|
9689
9747
|
return scn.wavs ? scn.wavs.slice() : defaultWavs();
|
|
9690
9748
|
}
|
|
@@ -9831,6 +9889,9 @@ async function packBuiltMap(input) {
|
|
|
9831
9889
|
extras: members,
|
|
9832
9890
|
editorMembers: /* @__PURE__ */ new Map([[BUILD_SOURCE_MEMBER, input.sourceChk], [BUILD_MANIFEST_MEMBER, new TextEncoder().encode(JSON.stringify(manifest))]]),
|
|
9833
9891
|
stored: input.stored,
|
|
9892
|
+
referenced: (function* () {
|
|
9893
|
+
yield* referencedMembers(parseScenario(out.chk));
|
|
9894
|
+
})(),
|
|
9834
9895
|
compress: compression,
|
|
9835
9896
|
encrypt,
|
|
9836
9897
|
sectorSize: requiredSectorSize(input.stored, compression === "zlib" ? 65536 : STAREDIT_SECTOR_SIZE)
|
|
@@ -9934,6 +9995,9 @@ function writeArchiveBytes(chk, options = {}) {
|
|
|
9934
9995
|
return saveMap(chk, {
|
|
9935
9996
|
extras: options.extras,
|
|
9936
9997
|
stored: options.stored ?? null,
|
|
9998
|
+
referenced: (function* () {
|
|
9999
|
+
yield* referencedMembers(parseScenario(chk));
|
|
10000
|
+
})(),
|
|
9937
10001
|
compress: compression,
|
|
9938
10002
|
encrypt: options.encrypt ?? false,
|
|
9939
10003
|
listfile: options.listfile ?? true,
|
|
@@ -16316,7 +16380,7 @@ function kindKey(tileset, tile) {
|
|
|
16316
16380
|
return key;
|
|
16317
16381
|
}
|
|
16318
16382
|
//#endregion
|
|
16319
|
-
//#region src/editor/borrowTable.ts
|
|
16383
|
+
//#region src/editor/modTerrain/borrowTable.ts
|
|
16320
16384
|
/**
|
|
16321
16385
|
* The borrowed-terrain table (see `borrow.ts`): which host megatiles are copies of which source
|
|
16322
16386
|
* megatiles, and which host tile stands for each source tile. Apart from the rest of `borrow.ts`
|
|
@@ -16674,7 +16738,7 @@ function tableCounts(source, table) {
|
|
|
16674
16738
|
return out;
|
|
16675
16739
|
}
|
|
16676
16740
|
//#endregion
|
|
16677
|
-
//#region src/editor/borrow.ts
|
|
16741
|
+
//#region src/editor/modTerrain/borrow.ts
|
|
16678
16742
|
/** A terrain is whole with stand-ins for at most this share of its tiles (a tenth): the odd missing tile, not the terrain. */
|
|
16679
16743
|
var STAND_IN_SHARE = .1;
|
|
16680
16744
|
/**
|
|
@@ -16874,7 +16938,7 @@ function seamStep(tileset, a, side, b) {
|
|
|
16874
16938
|
return edgeDistance(edgeTable(tileset), a, side, b, OPPOSITE[side]) - (grain[a * 4 + SIDE_INDEX$1[side]] + grain[b * 4 + SIDE_INDEX$1[OPPOSITE[side]]]) / 2;
|
|
16875
16939
|
}
|
|
16876
16940
|
//#endregion
|
|
16877
|
-
//#region src/editor/borderRecord.ts
|
|
16941
|
+
//#region src/editor/modTerrain/borderRecord.ts
|
|
16878
16942
|
/** The member holding the border record for tileset `sourceEra` (`scmjs\borders-install.bin`). */
|
|
16879
16943
|
var bordersMember = (sourceEra) => `scmjs\\borders-${TILESETS[sourceEra & 7].id}.bin`;
|
|
16880
16944
|
var BORDER_MEMBERS = TILESETS.map((_, era) => bordersMember(era));
|
|
@@ -17118,7 +17182,7 @@ function standInFor(sis, patchHeight, groundHeight) {
|
|
|
17118
17182
|
return patchHeight === groundHeight ? sis.flat : patchHeight > groundHeight ? sis.up : sis.down;
|
|
17119
17183
|
}
|
|
17120
17184
|
//#endregion
|
|
17121
|
-
//#region src/editor/borderTable.ts
|
|
17185
|
+
//#region src/editor/modTerrain/borderTable.ts
|
|
17122
17186
|
/**
|
|
17123
17187
|
* Drawn borders, the table: which tile a tileset's maps lay for each shape of the border between a borrowed terrain
|
|
17124
17188
|
* (X, a terrain of another tileset laid by the borrowed brush, `borrow.ts`) and the tileset's own ground (Y).
|
|
@@ -17542,7 +17606,7 @@ function poolOf(setup, table) {
|
|
|
17542
17606
|
return pool;
|
|
17543
17607
|
}
|
|
17544
17608
|
//#endregion
|
|
17545
|
-
//#region src/editor/borderPass.ts
|
|
17609
|
+
//#region src/editor/modTerrain/borderPass.ts
|
|
17546
17610
|
/**
|
|
17547
17611
|
* Drawn borders, the pass: lay the border cells of a borrowed patch from the pair's table (`borderTable.ts`), with the
|
|
17548
17612
|
* seams as the judge.
|
|
@@ -17783,7 +17847,7 @@ function withoutStack(shape) {
|
|
|
17783
17847
|
return parts.length === 3 ? `${parts[0]}|${parts[2]}` : shape;
|
|
17784
17848
|
}
|
|
17785
17849
|
//#endregion
|
|
17786
|
-
//#region src/editor/borrowLattice.ts
|
|
17850
|
+
//#region src/editor/modTerrain/borrowLattice.ts
|
|
17787
17851
|
/**
|
|
17788
17852
|
* The isometric brush laying a borrowed terrain (`borrow.ts`): StarEdit's own brush, run on a
|
|
17789
17853
|
* lattice in the *source* tileset's numbering, each tile it lays written into the map as a host
|
|
@@ -18555,7 +18619,7 @@ function borrowedCells(size, sourceEra, isom, base) {
|
|
|
18555
18619
|
return out;
|
|
18556
18620
|
}
|
|
18557
18621
|
//#endregion
|
|
18558
|
-
//#region src/editor/terrainCopyTable.ts
|
|
18622
|
+
//#region src/editor/modTerrain/terrainCopyTable.ts
|
|
18559
18623
|
/**
|
|
18560
18624
|
* Copied terrain, the table: a tileset that holds one of its own typed terrains again under other flags (an untyped
|
|
18561
18625
|
* flat pair whose every picture is the terrain's — `palette.ts#terrainCopies`, "Mud (mid ground)") often holds that
|
|
@@ -19040,7 +19104,7 @@ function decodeCopyBlocks(text) {
|
|
|
19040
19104
|
}
|
|
19041
19105
|
}
|
|
19042
19106
|
//#endregion
|
|
19043
|
-
//#region src/editor/terrainCopyLattice.ts
|
|
19107
|
+
//#region src/editor/modTerrain/terrainCopyLattice.ts
|
|
19044
19108
|
/**
|
|
19045
19109
|
* Copied terrain, the brush (the table is `terrainCopyTable.ts`): a copied terrain S is laid by the game's own
|
|
19046
19110
|
* isometric brush on a *shadow* — a scenario in the tileset's own numbering filled with the edge set's other terrain O —
|
|
@@ -20107,7 +20171,7 @@ function placeDoodad(scn, def, tx, ty, owner, tileAt = (at) => scn.tiles[at]) {
|
|
|
20107
20171
|
};
|
|
20108
20172
|
}
|
|
20109
20173
|
//#endregion
|
|
20110
|
-
//#region src/editor/tileSheet.ts
|
|
20174
|
+
//#region src/editor/modTerrain/tileSheet.ts
|
|
20111
20175
|
/** Slots in a CV5 group: the sheet's width. */
|
|
20112
20176
|
var SHEET_COLUMNS = 16;
|
|
20113
20177
|
/**
|
|
@@ -20311,7 +20375,7 @@ var PatternStroke = class {
|
|
|
20311
20375
|
}
|
|
20312
20376
|
};
|
|
20313
20377
|
//#endregion
|
|
20314
|
-
//#region src/editor/pieces.ts
|
|
20378
|
+
//#region src/editor/modTerrain/pieces.ts
|
|
20315
20379
|
/**
|
|
20316
20380
|
* Pieces: the parts of a tileset's sheet that maps lay whole.
|
|
20317
20381
|
*
|
|
@@ -20484,7 +20548,7 @@ function decodeEvidence(data) {
|
|
|
20484
20548
|
return part === 3 ? out : null;
|
|
20485
20549
|
}
|
|
20486
20550
|
//#endregion
|
|
20487
|
-
//#region src/editor/pieceLearn.ts
|
|
20551
|
+
//#region src/editor/modTerrain/pieceLearn.ts
|
|
20488
20552
|
/**
|
|
20489
20553
|
* Learning pieces from a folder of maps: every map is opened, and the tiles of one that the
|
|
20490
20554
|
* data set in use has all of are counted against its tileset's sheet (`pieces.ts`). A map that
|
|
@@ -20581,7 +20645,7 @@ function tableHash(groups) {
|
|
|
20581
20645
|
return out;
|
|
20582
20646
|
}
|
|
20583
20647
|
//#endregion
|
|
20584
|
-
//#region src/editor/tileCopies.ts
|
|
20648
|
+
//#region src/editor/modTerrain/tileCopies.ts
|
|
20585
20649
|
/**
|
|
20586
20650
|
* The same tile twice: a mod's tileset repeats the game's pictures and its own, so the Tile
|
|
20587
20651
|
* palette's lists would show one picture many times. "The same tile" is the same picture *and*
|
|
@@ -20776,7 +20840,7 @@ function collapsePieces(tileset, pieces) {
|
|
|
20776
20840
|
/** Every piece an entry stands for. */
|
|
20777
20841
|
var entryPieces = (e) => [e.piece, ...e.copies];
|
|
20778
20842
|
//#endregion
|
|
20779
|
-
//#region src/editor/piecePick.ts
|
|
20843
|
+
//#region src/editor/modTerrain/piecePick.ts
|
|
20780
20844
|
/**
|
|
20781
20845
|
* Which piece the map lays at a cell, for Alt+click: the cell's tile must be one of a piece's,
|
|
20782
20846
|
* and laid beside at least one of its sheet neighbours from the same piece — the tile alone
|
|
@@ -20807,7 +20871,7 @@ function laidPieceAt(map, groupCount, index, x, y) {
|
|
|
20807
20871
|
return beside.some((b, i) => b && index.get(neighbours[i]) === piece) ? piece : null;
|
|
20808
20872
|
}
|
|
20809
20873
|
//#endregion
|
|
20810
|
-
//#region src/editor/pieceList.ts
|
|
20874
|
+
//#region src/editor/modTerrain/pieceList.ts
|
|
20811
20875
|
/**
|
|
20812
20876
|
* What the Pieces view lists, and `api.terrain.pieces()` answers: named pieces plugins provide,
|
|
20813
20877
|
* a section for each set, ahead of the pieces cut from maps (`pieces.ts`, folded by
|
|
@@ -26291,11 +26355,11 @@ function same(a, b) {
|
|
|
26291
26355
|
* the source tiles that are only stand-ins (the nearest picture where the tileset has no copy), so the terrains a
|
|
26292
26356
|
* file offers are the ones a scan would;
|
|
26293
26357
|
* - `borders`: drawn borders between a borrowed terrain and the tileset's own ground (what `provideBorderTable` takes):
|
|
26294
|
-
* per pair, the tiles to lay for each border shape, the shapes named as the editor reads them (`editor/borderLattice.ts`);
|
|
26358
|
+
* per pair, the tiles to lay for each border shape, the shapes named as the editor reads them (`editor/modTerrain/borderLattice.ts`);
|
|
26295
26359
|
* - `copies`: copied terrain (what `provideCopies` takes): per block, the terrain copied, the copy's height, the ground
|
|
26296
26360
|
* its pieces meet, and the tile standing for each piece of the terrain's edge set.
|
|
26297
26361
|
*
|
|
26298
|
-
* Each tileset's section names the group table its numbers are for (`table`, `editor/pieceLearn.ts#tableHash`, the
|
|
26362
|
+
* Each tileset's section names the group table its numbers are for (`table`, `editor/modTerrain/pieceLearn.ts#tableHash`, the
|
|
26299
26363
|
* hash learned pieces are kept under); a tileset whose table has another hash does not use the section.
|
|
26300
26364
|
*
|
|
26301
26365
|
* Like `mod.json` it is none of the mod's game files, so the mod's hash does not change with it. The reader never
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scm-js/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "StarCraft: Brood War maps in Node.js and the browser, as the scmJS editor reads and writes them: open .scm/.scx/.chk, triggers, strings, units, locations, settings, Check Map, and write the map back",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"starcraft",
|