dredless 0.6.3 → 0.7.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.
@@ -1,5 +1,4 @@
1
1
  import * as modelDecoder from "./decoder.js";
2
- import {LoaderConfigTracker} from "./loader-config.js";
3
2
  import {navigationDestinationFromEncodedValue} from "../overworld.js";
4
3
 
5
4
  const {
@@ -47,9 +46,6 @@ const {
47
46
  blobKey,
48
47
  cloneRecord,
49
48
  firstRecord,
50
- TABLE_78_FIELD_BITS,
51
- table78DeltaRecord,
52
- isSemanticLoaderDelta,
53
49
  decodeText,
54
50
  entityNameFromType,
55
51
  markerTypeIdForTables,
@@ -126,7 +122,6 @@ const {
126
122
  } = modelDecoder;
127
123
 
128
124
  export class ModelState {
129
- #loaderConfig = new LoaderConfigTracker();
130
125
  #blueprintItems = null;
131
126
  #helmOccupied = new Map();
132
127
  #commsStationOccupied = new Map();
@@ -236,8 +231,6 @@ export class ModelState {
236
231
  pushCapped(this.errors, {message: error.message, generation: update.generation}, MAX_RETAINED_ERRORS);
237
232
  }
238
233
 
239
- this.#remapIndexedLoaderConfig(update);
240
- this.#updateLoaderConfig(update);
241
234
  this.#updateNavigationUnitAutoWarp(update);
242
235
  this.#updateHelmOccupancy(update);
243
236
  this.#updateCommsStationOccupancy(update);
@@ -354,60 +347,6 @@ export class ModelState {
354
347
  this._derived.tableSummariesDirty = true;
355
348
  }
356
349
 
357
- #updateLoaderConfig(update) {
358
- const seenEntities = new Set();
359
- for (const section of update.sections || []) {
360
- if (section.table !== 78) continue;
361
- for (const changed of section.records || []) {
362
- if (changed.indexedLoaderConfig) {
363
- this.#loaderConfig.updateIndexedSnapshotRecord(null, changed.entity, changed.record, changed.mask, changed.cumulativeRecord, changed.configEntity);
364
- continue;
365
- }
366
- const typeId = entityTypeIdFromRecord(this.record(7, changed.entity));
367
- this.#loaderConfig.updateRecord(null, changed.entity, changed.record ?? this.record(78, changed.entity), changed.mask, changed.previous, {
368
- repeatedInUpdate: seenEntities.has(changed.entity),
369
- allowSparseBaseline: typeId === LOADER_TYPE_ID,
370
- repeatedInSection: changed.repeatedInSection,
371
- semanticSnapshot: Boolean(update.full),
372
- semanticDelta: isSemanticLoaderDelta(changed, update.full),
373
- deltaRecord: table78DeltaRecord(changed)
374
- });
375
- seenEntities.add(changed.entity);
376
- }
377
- }
378
- }
379
-
380
- #remapIndexedLoaderConfig(update) {
381
- if (!update.full || update.error) return;
382
- const rows = [];
383
- for (const section of update.sections || []) {
384
- if (section.table !== 78) continue;
385
- for (const changed of section.records || []) rows.push(changed);
386
- }
387
- if (!rows.length) return;
388
-
389
- const loaderIds = [...this.table(7).entries()]
390
- .filter(([, record]) => entityTypeIdFromRecord(record) === LOADER_TYPE_ID)
391
- .map(([entity]) => entity)
392
- .sort((a, b) => a - b);
393
- if (loaderIds.length !== rows.length) return;
394
- if (rows.every((row, index) => row.entity === loaderIds[index])) return;
395
-
396
- const remappedTable = new Map();
397
- for (const [index, changed] of rows.entries()) {
398
- const rawRecord = table78DeltaRecord(changed);
399
- changed.configEntity = changed.entity;
400
- changed.entity = loaderIds[index];
401
- changed.cumulativeRecord = cloneRecord(changed.record || {});
402
- changed.record = cloneRecord(rawRecord);
403
- delete changed.previous;
404
- changed.indexedLoaderConfig = true;
405
- remappedTable.set(changed.entity, cloneRecord(rawRecord));
406
- update.changedEntities.add(changed.entity);
407
- }
408
- this.tables.set(78, remappedTable);
409
- }
410
-
411
350
  #updateNavigationUnitAutoWarp(update) {
412
351
  const trackedBeforeUpdate = new Set(this.#navigationUnitAutoWarp.keys());
413
352
  const initializedThisUpdate = new Set();
@@ -829,7 +768,8 @@ export class ModelState {
829
768
  const pusherRecord = rec(72);
830
769
  const pusherBeamRecord = rec(42);
831
770
  const launcherRecord = rec(44);
832
- const loaderRecord = rec(78);
771
+ const loaderRecord = rec(69);
772
+ const navigationRecord = rec(78);
833
773
  const loaderFilterRecord = rec(76);
834
774
  const loaderFilterSlotsRecord = rec(77);
835
775
  const commsStationRecord = rec(39);
@@ -864,16 +804,16 @@ export class ModelState {
864
804
  const health = summarizeHealth(entityId, healthRecord);
865
805
  const fabricator = summarizeFabricator(entityId, fabricatorRecord, itemHolderRecord, typeRecord);
866
806
  const cargoEjector = summarizeCargoEjector(entityId, typeId, cargoEjectorRecord);
867
- const cannon = summarizeCannon(entityId, cannonRecord, typeId);
807
+ const cannon = summarizeCannon(entityId, cannonRecord, typeId, transformRecord);
868
808
  const thruster = summarizeThruster(entityId, typeId, thrusterRecord);
869
809
  const pusher = summarizePusher(entityId, pusherRecord, loaderFilterSlotsRecord);
870
810
  const pusherBeam = summarizePusherBeam(entityId, pusherBeamRecord);
871
811
  const launcher = summarizeItemLauncher(entityId, typeId, launcherRecord);
872
812
  const loader = (typeId === LOADER_TYPE_ID || (typeId == null && (loaderRecord || loaderFilterRecord || loaderFilterSlotsRecord)))
873
- ? summarizeLoader(entityId, loaderRecord, loaderFilterRecord, loaderFilterSlotsRecord, this.#loaderConfig, typeId === LOADER_TYPE_ID, itemHolderRecord)
813
+ ? summarizeLoader(entityId, loaderRecord, loaderFilterRecord, loaderFilterSlotsRecord, typeId === LOADER_TYPE_ID, itemHolderRecord)
874
814
  : null;
875
815
  const cargoHatch = summarizeCargoHatch(entityId, typeId, loaderFilterRecord, loaderFilterSlotsRecord, rec(45));
876
- const navigationUnit = summarizeNavigationUnit(entityId, typeId, loaderRecord, this.#navigationUnitAutoWarp.get(entityId));
816
+ const navigationUnit = summarizeNavigationUnit(entityId, typeId, navigationRecord, this.#navigationUnitAutoWarp.get(entityId));
877
817
  const fluidTank = fluidTankRecord ? {
878
818
  entity: entityId,
879
819
  amount: fluidTankRecord.q24 ?? null,
@@ -1111,7 +1051,6 @@ export class ModelState {
1111
1051
  } else {
1112
1052
  for (const records of this.tables.values()) records.delete(entity);
1113
1053
  }
1114
- this.#loaderConfig.delete(null, entity);
1115
1054
  this.#helmOccupied.delete(entity);
1116
1055
  this.#commsStationOccupied.delete(entity);
1117
1056
  this.#navigationUnitAutoWarp.delete(entity);
@@ -1129,7 +1068,6 @@ export class ModelState {
1129
1068
  #readSectionRecords(reader, tag, tableId, spec) {
1130
1069
  const section = {tag, table: tableId, name: spec?.name || null, records: []};
1131
1070
  let entity = 0;
1132
- const seenEntities = tableId === 78 ? new Set() : null;
1133
1071
  while (reader.remaining > 0) {
1134
1072
  const recordOffset = reader.offset;
1135
1073
  let delta;
@@ -1147,7 +1085,6 @@ export class ModelState {
1147
1085
  throw new Error(`model table ${tableId} tag ${tag} entity ${entity} mask offset ${reader.offset}: ${error.message}`);
1148
1086
  }
1149
1087
  const record = this.#getRecord(tableId, entity);
1150
- const previous = tableId === 78 ? cloneRecord(record) : null;
1151
1088
  record.lastMask = mask;
1152
1089
 
1153
1090
  try {
@@ -1158,10 +1095,6 @@ export class ModelState {
1158
1095
  }
1159
1096
 
1160
1097
  const changed = {entity, mask};
1161
- if (previous) changed.previous = previous;
1162
- if (seenEntities?.has(entity)) changed.repeatedInSection = true;
1163
- seenEntities?.add(entity);
1164
- if (tableId === 78) changed.record = cloneRecord(record);
1165
1098
  section.records.push(changed);
1166
1099
  }
1167
1100
  return section;
@@ -1170,7 +1103,7 @@ export class ModelState {
1170
1103
  #getRecord(tableId, entity) {
1171
1104
  if (!this.tables.has(tableId)) this.tables.set(tableId, new Map());
1172
1105
  const records = this.tables.get(tableId);
1173
- if (!records.has(entity)) records.set(entity, {});
1106
+ if (!records.has(entity)) records.set(entity, {...MODEL_TABLE_SPECS.get(tableId)?.defaults});
1174
1107
  return records.get(entity);
1175
1108
  }
1176
1109