Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

satisfactory-json

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

satisfactory-json - npm Package Compare versions

Comparing version 0.0.17 to 0.0.18

lib/Archive.d.ts

2

lib/DataBuffer.d.ts

@@ -7,3 +7,3 @@ /// <reference types="node" />

}
export declare class DataBuffer {
export declare class Archive {
buffer: Buffer;

@@ -10,0 +10,0 @@ cursor: number;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class DataBuffer {
class Archive {
constructor(buffer) {

@@ -284,2 +284,2 @@ //#endregion

}
exports.DataBuffer = DataBuffer;
exports.Archive = Archive;
/// <reference types="node" />
import { SaveGame } from './types';
import { DataBuffer } from './DataBuffer';
/**
*
* @param toSav direction in which to transform. false: sav2json, true: json2sav
*/
export declare function transform(buffer: DataBuffer, saveGame: SaveGame, toSav: boolean): void;
export declare function sav2json(buffer: Buffer): SaveGame;
export declare function json2sav(saveGame: SaveGame): string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const DataBuffer_1 = require("./DataBuffer");
const Property_1 = require("./transforms/Property");
const Extra_1 = require("./transforms/Extra");
const Archive_1 = require("./Archive");
const Actor_1 = require("./transforms/Actor");
const Entity_1 = require("./transforms/Entity");
const Component_1 = require("./transforms/Component");
function sav2json(buffer) {
const saveGame = {
saveHeaderType: 0,
saveVersion: 0,
buildVersion: 0,
mapName: '',
mapOptions: '',
sessionName: '',
playDurationSeconds: 0,
saveDateTime: '',
sessionVisibility: 0,
actors: [],
components: [],
collected: [],
missing: ''
};
transform(new Archive_1.LoadingArchive(buffer), saveGame);
return saveGame;
}
exports.sav2json = sav2json;
function json2sav(saveGame) {
const buffer = new Archive_1.SavingArchive(Buffer.from([]));
transform(buffer, saveGame);
return buffer.getOutput();
}
exports.json2sav = json2sav;
/**

@@ -10,20 +37,20 @@ *

*/
function transform(buffer, saveGame, toSav) {
transformHeader(buffer, saveGame, toSav);
function transform(ar, saveGame) {
transformHeader(ar, saveGame);
const entryCount = {
entryCount: saveGame.actors.length + saveGame.components.length
};
buffer.transformInt(entryCount, 'entryCount', toSav);
ar.transformInt(entryCount, 'entryCount');
for (let i = 0; i < entryCount.entryCount; i++) {
transformActorOrComponent(buffer, saveGame, i, toSav);
transformActorOrComponent(ar, saveGame, i);
}
buffer.transformInt(entryCount, 'entryCount', toSav);
ar.transformInt(entryCount, 'entryCount');
for (let i = 0; i < entryCount.entryCount; i++) {
if (i < saveGame.actors.length) {
const actor = saveGame.actors[i];
transformEntity(buffer, actor.entity, true, actor.className, toSav);
Entity_1.default(ar, actor.entity, true, actor.className);
}
else {
const component = saveGame.components[i - saveGame.actors.length];
transformEntity(buffer, component.entity, false, component.className, toSav);
Entity_1.default(ar, component.entity, false, component.className);
}

@@ -34,30 +61,30 @@ }

};
buffer.transformInt(collectedCount, 'count', toSav);
ar.transformInt(collectedCount, 'count');
for (let i = 0; i < collectedCount.count; i++) {
if (!toSav) {
if (ar.isLoading()) {
saveGame.collected.push({ levelName: '', pathName: '' });
}
buffer.transformString(saveGame.collected[i], 'levelName', toSav);
buffer.transformString(saveGame.collected[i], 'pathName', toSav);
ar.transformString(saveGame.collected[i], 'levelName');
ar.transformString(saveGame.collected[i], 'pathName');
}
// TODO missing
}
exports.transform = transform;
function transformHeader(buffer, saveGame, toSav) {
buffer.transformInt(saveGame, 'saveHeaderType', toSav);
buffer.transformInt(saveGame, 'saveVersion', toSav);
buffer.transformInt(saveGame, 'buildVersion', toSav);
buffer.transformString(saveGame, 'mapName', toSav);
buffer.transformString(saveGame, 'mapOptions', toSav);
buffer.transformString(saveGame, 'sessionName', toSav);
buffer.transformInt(saveGame, 'playDurationSeconds', toSav);
buffer.transformLong(saveGame, 'saveDateTime', toSav);
function transformHeader(buffer, saveGame) {
buffer.transformInt(saveGame, 'saveHeaderType');
buffer.transformInt(saveGame, 'saveVersion');
buffer.transformInt(saveGame, 'buildVersion');
buffer.transformString(saveGame, 'mapName');
buffer.transformString(saveGame, 'mapOptions');
buffer.transformString(saveGame, 'sessionName');
buffer.transformInt(saveGame, 'playDurationSeconds');
buffer.transformLong(saveGame, 'saveDateTime');
if (saveGame.saveHeaderType > 4) {
buffer.transformByte(saveGame, 'sessionVisibility', toSav);
buffer.transformByte(saveGame, 'sessionVisibility');
}
}
function transformActorOrComponent(buffer, saveGame, id, toSav) {
if (!toSav) {
const type = buffer.readInt();
if (type === 1) {
function transformActorOrComponent(ar, saveGame, id) {
const type = { type: id < saveGame.actors.length ? 1 : 0 };
ar.transformInt(type, 'type');
if (ar.isLoading()) {
if (type.type === 1) {
const actor = {

@@ -80,6 +107,6 @@ type: 1,

};
transformActor(buffer, actor, toSav);
Actor_1.default(ar, actor);
saveGame.actors.push(actor);
}
else if (type === 0) {
else if (type.type === 0) {
const component = {

@@ -95,7 +122,7 @@ type: 0,

};
transformComponent(buffer, component, toSav);
Component_1.default(ar, component);
saveGame.components.push(component);
}
else {
throw new Error(`Unknown type ${type}`);
throw new Error(`Unknown type ${type.type}`);
}

@@ -105,147 +132,8 @@ }

if (id < saveGame.actors.length) {
buffer.writeInt(1);
transformActor(buffer, saveGame.actors[id], toSav);
Actor_1.default(ar, saveGame.actors[id]);
}
else {
buffer.writeInt(0);
transformComponent(buffer, saveGame.components[id - saveGame.actors.length], toSav);
Component_1.default(ar, saveGame.components[id - saveGame.actors.length]);
}
}
}
function transformActor(buffer, actor, toSav) {
buffer.transformString(actor, 'className', toSav);
buffer.transformString(actor, 'levelName', toSav);
buffer.transformString(actor, 'pathName', toSav);
buffer.transformInt(actor, 'needTransform', toSav);
buffer.transformFloat(actor.transform.rotation, 0, toSav);
buffer.transformFloat(actor.transform.rotation, 1, toSav);
buffer.transformFloat(actor.transform.rotation, 2, toSav);
buffer.transformFloat(actor.transform.rotation, 3, toSav);
buffer.transformFloat(actor.transform.translation, 0, toSav);
buffer.transformFloat(actor.transform.translation, 1, toSav);
buffer.transformFloat(actor.transform.translation, 2, toSav);
buffer.transformFloat(actor.transform.scale3d, 0, toSav);
buffer.transformFloat(actor.transform.scale3d, 1, toSav);
buffer.transformFloat(actor.transform.scale3d, 2, toSav);
buffer.transformInt(actor, 'wasPlacedInLevel', toSav);
}
function transformComponent(buffer, component, toSav) {
buffer.transformString(component, 'className', toSav);
buffer.transformString(component, 'levelName', toSav);
buffer.transformString(component, 'pathName', toSav);
buffer.transformString(component, 'outerPathName', toSav);
}
/* interface Reference {
obj: any;
key: Key;
}
function ref(obj: any, key: Key): Reference {
return {
obj,
key
};
}
*/
function transformEntity(buffer, entity, withNames, className, toSav) {
const length = buffer.transformBufferStart(toSav, true);
if (withNames) {
buffer.transformString(entity, 'levelName', toSav);
buffer.transformString(entity, 'pathName', toSav);
const childCount = { count: entity.children.length };
buffer.transformInt(childCount, 'count', toSav);
for (let i = 0; i < childCount.count; i++) {
if (!toSav) {
entity.children.push({ levelName: '', pathName: '' });
}
buffer.transformString(entity.children[i], 'levelName', toSav);
buffer.transformString(entity.children[i], 'pathName', toSav);
}
}
transformProperties(buffer, entity, toSav);
const extraObjectCount = { count: 0 };
buffer.transformInt(extraObjectCount, 'count', toSav);
if (extraObjectCount.count !== 0) {
throw Error(`Extra object count not zero, but ${extraObjectCount.count}`);
}
// read extra
Extra_1.default(buffer, entity, toSav, className, length);
// read missing
if (toSav) {
if (entity.missing !== undefined) {
buffer.writeHex(entity.missing);
}
}
else {
const missing = length - buffer.bytesRead;
if (missing > 0) {
entity.missing = buffer.readHex(missing);
console.warn('missing data found in entity of type ' +
className +
': ' +
entity.missing);
}
else if (missing < 0) {
throw Error('negative missing amount in entity of type ' +
className +
': ' +
missing);
}
}
// console.log('finished entity', entity);
buffer.transformBufferEnd(toSav);
}
function transformProperties(buffer, entity, toSav) {
// console.log(entity);
if (toSav) {
for (const property of entity.properties) {
buffer.transformString(property, 'name', toSav);
Property_1.default(buffer, property, toSav);
}
buffer.writeLengthPrefixedString('None'); // end of properties
}
else {
// read properties
while (true) {
const property = {
name: '',
type: '',
index: 0,
value: ''
};
buffer.transformString(property, 'name', toSav);
if (property.name === 'None') {
break; // end of properties
}
Property_1.default(buffer, property, toSav);
entity.properties.push(property);
// console.log('property built', property);
}
}
}
function sav2json(buffer) {
const saveGame = {
saveHeaderType: 0,
saveVersion: 0,
buildVersion: 0,
mapName: '',
mapOptions: '',
sessionName: '',
playDurationSeconds: 0,
saveDateTime: '',
sessionVisibility: 0,
actors: [],
components: [],
collected: [],
missing: ''
};
transform(new DataBuffer_1.DataBuffer(buffer), saveGame, false);
return saveGame;
}
exports.sav2json = sav2json;
function json2sav(saveGame) {
const buffer = new DataBuffer_1.DataBuffer(Buffer.from([]));
transform(buffer, saveGame, true);
return buffer.bytes;
}
exports.json2sav = json2sav;

@@ -1,3 +0,3 @@

import { DataBuffer } from '../DataBuffer';
import { Archive } from '../Archive';
import { Entity } from '../types';
export default function transformExtra(buffer: DataBuffer, entity: Entity, toSav: boolean, className: string, length: number): void;
export default function transformExtra(ar: Archive, entity: Entity, className: string, length: number): void;

@@ -12,21 +12,21 @@ "use strict";

const Train_1 = require("./extras/Train");
function transformExtra(buffer, entity, toSav, className, length) {
function transformExtra(ar, entity, className, length) {
switch (className) {
case '/Game/FactoryGame/Buildable/Factory/PowerLine/Build_PowerLine.Build_PowerLine_C':
PowerLine_1.default(buffer, entity, toSav);
PowerLine_1.default(ar, entity);
break;
case '/Game/FactoryGame/-Shared/Blueprint/BP_CircuitSubsystem.BP_CircuitSubsystem_C':
CircuitSubsystem_1.default(buffer, entity, toSav);
CircuitSubsystem_1.default(ar, entity);
break;
case '/Game/FactoryGame/-Shared/Blueprint/BP_GameMode.BP_GameMode_C':
GameMode_1.default(buffer, entity, toSav);
GameMode_1.default(ar, entity);
break;
case '/Game/FactoryGame/-Shared/Blueprint/BP_GameState.BP_GameState_C':
GameState_1.default(buffer, entity, toSav);
GameState_1.default(ar, entity);
break;
case '/Game/FactoryGame/-Shared/Blueprint/BP_RailroadSubsystem.BP_RailroadSubsystem_C':
RailroadSubsystem_1.default(buffer, entity, toSav, length);
RailroadSubsystem_1.default(ar, entity, length);
break;
case '/Game/FactoryGame/Character/Player/BP_PlayerState.BP_PlayerState_C':
PlayerState_1.default(buffer, entity, toSav, length);
PlayerState_1.default(ar, entity, length);
break;

@@ -36,3 +36,3 @@ case '/Game/FactoryGame/Buildable/Vehicle/Tractor/BP_Tractor.BP_Tractor_C':

case '/Game/FactoryGame/Buildable/Vehicle/Explorer/BP_Explorer.BP_Explorer_C':
Vehicle_1.default(buffer, entity, toSav);
Vehicle_1.default(ar, entity);
break;

@@ -53,7 +53,7 @@ // tslint:disable: max-line-length

// tslint:enable
ConveyorBelt_1.default(buffer, entity, toSav, length);
ConveyorBelt_1.default(ar, entity, length);
break;
case '/Game/FactoryGame/Buildable/Vehicle/Train/Wagon/BP_FreightWagon.BP_FreightWagon_C':
case '/Game/FactoryGame/Buildable/Vehicle/Train/Locomotive/BP_Locomotive.BP_Locomotive_C':
Train_1.default(buffer, entity, toSav, length);
Train_1.default(ar, entity, length);
break;

@@ -60,0 +60,0 @@ }

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../DataBuffer';
import { Archive } from '../../Archive';
import { Entity } from '../../types';
export default function transformCircuitSubsystem(buffer: DataBuffer, entity: Entity, toSav: boolean): void;
export default function transformCircuitSubsystem(ar: Archive, entity: Entity): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function transformCircuitSubsystem(buffer, entity, toSav) {
if (!toSav) {
function transformCircuitSubsystem(ar, entity) {
if (ar.isLoading()) {
entity.extra = {

@@ -10,12 +10,12 @@ circuits: []

const circuits = { length: entity.extra.circuits.length };
buffer.transformInt(circuits, 'length', toSav);
ar.transformInt(circuits, 'length');
for (let i = 0; i < circuits.length; i++) {
if (!toSav) {
if (ar.isLoading()) {
entity.extra.circuits.push({});
}
buffer.transformInt(entity.extra.circuits[i], 'circuitId', toSav);
buffer.transformString(entity.extra.circuits[i], 'levelName', toSav);
buffer.transformString(entity.extra.circuits[i], 'pathName', toSav);
ar.transformInt(entity.extra.circuits[i], 'circuitId');
ar.transformString(entity.extra.circuits[i], 'levelName');
ar.transformString(entity.extra.circuits[i], 'pathName');
}
}
exports.default = transformCircuitSubsystem;

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../DataBuffer';
import { Archive } from '../../Archive';
import { Entity } from '../../types';
export default function transformConveyorBelt(buffer: DataBuffer, entity: Entity, toSav: boolean, length: number): void;
export default function transformConveyorBelt(ar: Archive, entity: Entity, length: number): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function transformConveyorBelt(buffer, entity, toSav, length) {
if (!toSav) {
function transformConveyorBelt(ar, entity, length) {
if (ar.isLoading()) {
entity.extra = {

@@ -10,6 +10,6 @@ items: []

const items = { length: entity.extra.items.length };
buffer.transformInt(items, 'length', toSav);
ar.transformInt(items, 'length');
for (let i = 0; i < items.length; i++) {
if (!toSav) {
if (buffer.bytesRead >= length) {
if (ar.isLoading()) {
if (ar.bytesRead >= length) {
console.warn('Item count is ' + items.length +

@@ -21,9 +21,9 @@ ' while there are only ' + i + ' items in there');

}
buffer.transformAssertNullInt(toSav);
buffer.transformString(entity.extra.items[i], 'name', toSav);
buffer.transformAssertNullInt(toSav);
buffer.transformAssertNullInt(toSav);
buffer.transformFloat(entity.extra.items[i], 'position', toSav);
ar.transformAssertNullInt();
ar.transformString(entity.extra.items[i], 'name');
ar.transformAssertNullInt();
ar.transformAssertNullInt();
ar.transformFloat(entity.extra.items[i], 'position');
}
}
exports.default = transformConveyorBelt;

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../DataBuffer';
import { Archive } from '../../Archive';
import { Entity } from '../../types';
export default function transformGameMode(buffer: DataBuffer, entity: Entity, toSav: boolean): void;
export default function transformGameMode(ar: Archive, entity: Entity): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function transformGameMode(buffer, entity, toSav) {
if (!toSav) {
function transformGameMode(ar, entity) {
if (ar.isLoading()) {
entity.extra = {

@@ -10,11 +10,11 @@ objects: []

const objects = { length: entity.extra.objects.length };
buffer.transformInt(objects, 'length', toSav);
ar.transformInt(objects, 'length');
for (let i = 0; i < objects.length; i++) {
if (!toSav) {
if (ar.isLoading()) {
entity.extra.objects.push({});
}
buffer.transformString(entity.extra.objects[i], 'levelName', toSav);
buffer.transformString(entity.extra.objects[i], 'pathName', toSav);
ar.transformString(entity.extra.objects[i], 'levelName');
ar.transformString(entity.extra.objects[i], 'pathName');
}
}
exports.default = transformGameMode;

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../DataBuffer';
import { Archive } from '../../Archive';
import { Entity } from '../../types';
export default function transformGameState(buffer: DataBuffer, entity: Entity, toSav: boolean): void;
export default function transformGameState(ar: Archive, entity: Entity): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function transformGameState(buffer, entity, toSav) {
if (!toSav) {
function transformGameState(ar, entity) {
if (ar.isLoading()) {
entity.extra = {

@@ -10,11 +10,11 @@ objects: []

const objects = { length: entity.extra.objects.length };
buffer.transformInt(objects, 'length', toSav);
ar.transformInt(objects, 'length');
for (let i = 0; i < objects.length; i++) {
if (!toSav) {
if (ar.isLoading()) {
entity.extra.objects.push({});
}
buffer.transformString(entity.extra.objects[i], 'levelName', toSav);
buffer.transformString(entity.extra.objects[i], 'pathName', toSav);
ar.transformString(entity.extra.objects[i], 'levelName');
ar.transformString(entity.extra.objects[i], 'pathName');
}
}
exports.default = transformGameState;

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../DataBuffer';
import { Archive } from '../../Archive';
import { Entity } from '../../types';
export default function transformPlayerState(buffer: DataBuffer, entity: Entity, toSav: boolean, length: number): void;
export default function transformPlayerState(ar: Archive, entity: Entity, length: number): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function transformPlayerState(buffer, entity, toSav, length) {
if (!toSav) {
function transformPlayerState(ar, entity, length) {
if (ar.isLoading()) {
entity.extra = {};

@@ -9,7 +9,7 @@ }

let count = 0;
if (!toSav) {
count = length - buffer.bytesRead;
if (ar.isLoading()) {
count = length - ar.bytesRead;
}
buffer.transformHex(entity.extra, 'unknown', count, toSav);
ar.transformHex(entity.extra, 'unknown', count);
}
exports.default = transformPlayerState;

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../DataBuffer';
import { Archive } from '../../Archive';
import { Entity } from '../../types';
export default function transformPowerLine(buffer: DataBuffer, entity: Entity, toSav: boolean): void;
export default function transformPowerLine(ar: Archive, entity: Entity): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function transformPowerLine(buffer, entity, toSav) {
if (!toSav) {
function transformPowerLine(ar, entity) {
if (ar.isLoading()) {
entity.extra = {};
}
buffer.transformString(entity.extra, 'sourceLevelName', toSav);
buffer.transformString(entity.extra, 'sourcePathName', toSav);
buffer.transformString(entity.extra, 'targetLevelName', toSav);
buffer.transformString(entity.extra, 'targetPathName', toSav);
ar.transformString(entity.extra, 'sourceLevelName');
ar.transformString(entity.extra, 'sourcePathName');
ar.transformString(entity.extra, 'targetLevelName');
ar.transformString(entity.extra, 'targetPathName');
}
exports.default = transformPowerLine;

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../DataBuffer';
import { Archive } from '../../Archive';
import { Entity } from '../../types';
export default function transformRailroadSubsystem(buffer: DataBuffer, entity: Entity, toSav: boolean, length: number): void;
export default function transformRailroadSubsystem(ar: Archive, entity: Entity, length: number): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function transformRailroadSubsystem(buffer, entity, toSav, length) {
if (toSav) {
function transformRailroadSubsystem(ar, entity, length) {
if (ar.isSaving()) {
// Workaround for broken savegames in the experimental version

@@ -12,3 +12,4 @@ if (entity.extra === undefined) { // TODO if saveHeaderVersion >= 6

// Workaround for broken savegames in the experimental version
if (buffer.bytesRead >= length) { // TODO replace with if saveHeaderType >= 6
if (ar.bytesRead >= length) {
// TODO replace with if saveHeaderType >= 6
return;

@@ -21,16 +22,16 @@ }

const trains = { length: entity.extra.trains.length };
buffer.transformInt(trains, 'length', toSav);
ar.transformInt(trains, 'length');
for (let i = 0; i < trains.length; i++) {
if (!toSav) {
if (ar.isLoading()) {
entity.extra.trains.push({});
}
buffer.transformHex(entity.extra.trains[i], 'unknown', 4, toSav);
buffer.transformString(entity.extra.trains[i], 'firstLevelName', toSav);
buffer.transformString(entity.extra.trains[i], 'firstPathName', toSav);
buffer.transformString(entity.extra.trains[i], 'secondLevelName', toSav);
buffer.transformString(entity.extra.trains[i], 'secondPathName', toSav);
buffer.transformString(entity.extra.trains[i], 'timetableLevelName', toSav);
buffer.transformString(entity.extra.trains[i], 'timetablePathName', toSav);
ar.transformHex(entity.extra.trains[i], 'unknown', 4);
ar.transformString(entity.extra.trains[i], 'firstLevelName');
ar.transformString(entity.extra.trains[i], 'firstPathName');
ar.transformString(entity.extra.trains[i], 'secondLevelName');
ar.transformString(entity.extra.trains[i], 'secondPathName');
ar.transformString(entity.extra.trains[i], 'timetableLevelName');
ar.transformString(entity.extra.trains[i], 'timetablePathName');
}
}
exports.default = transformRailroadSubsystem;

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../DataBuffer';
import { Archive } from '../../Archive';
import { Entity } from '../../types';
export default function transformTrain(buffer: DataBuffer, entity: Entity, toSav: boolean, length: number): void;
export default function transformTrain(ar: Archive, entity: Entity, length: number): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function transformTrain(buffer, entity, toSav, length) {
if (!toSav) {
function transformTrain(ar, entity, length) {
if (ar.isLoading()) {
entity.extra = {};
}
buffer.transformAssertNullInt(toSav);
buffer.transformString(entity.extra, 'previousLevelName', toSav);
buffer.transformString(entity.extra, 'previousPathName', toSav);
buffer.transformString(entity.extra, 'nextLevelName', toSav);
buffer.transformString(entity.extra, 'nextPathName', toSav);
ar.transformAssertNullInt();
ar.transformString(entity.extra, 'previousLevelName');
ar.transformString(entity.extra, 'previousPathName');
ar.transformString(entity.extra, 'nextLevelName');
ar.transformString(entity.extra, 'nextPathName');
}
exports.default = transformTrain;

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../DataBuffer';
import { Archive } from '../../Archive';
import { Entity } from '../../types';
export default function transformVehicle(buffer: DataBuffer, entity: Entity, toSav: boolean): void;
export default function transformVehicle(ar: Archive, entity: Entity): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function transformVehicle(buffer, entity, toSav) {
if (!toSav) {
function transformVehicle(ar, entity) {
if (ar.isLoading()) {
entity.extra = {

@@ -10,11 +10,11 @@ objects: []

const objects = { length: entity.extra.objects.length };
buffer.transformInt(objects, 'length', toSav);
ar.transformInt(objects, 'length');
for (let i = 0; i < objects.length; i++) {
if (!toSav) {
if (ar.isLoading()) {
entity.extra.objects.push({});
}
buffer.transformString(entity.extra.objects[i], 'name', toSav);
buffer.transformHex(entity.extra.objects[i], 'unknown', 53, toSav);
ar.transformString(entity.extra.objects[i], 'name');
ar.transformHex(entity.extra.objects[i], 'unknown', 53);
}
}
exports.default = transformVehicle;

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../DataBuffer';
import { Archive } from '../../Archive';
import { Property } from '../../types';
export default function transformArrayProperty(buffer: DataBuffer, property: Property, toSav: boolean): void;
export default function transformArrayProperty(ar: Archive, property: Property): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Property_1 = require("../Property");
function transformArrayProperty(buffer, property, toSav) {
if (!toSav) {
function transformArrayProperty(ar, property) {
if (ar.isLoading()) {
property.value = {

@@ -10,10 +10,10 @@ values: []

}
buffer.transformString(property.value, 'type', toSav, false);
buffer.transformAssertNullByte(toSav, false);
ar.transformString(property.value, 'type', false); // Tag.InnerType
ar.transformAssertNullByte(false); // Tag.HasPropertyGuid
const itemCount = { count: property.value.values.length };
buffer.transformInt(itemCount, 'count', toSav);
ar.transformInt(itemCount, 'count');
switch (property.value.type) {
case 'IntProperty':
for (let i = 0; i < itemCount.count; i++) {
buffer.transformInt(property.value.values, i, toSav);
ar.transformInt(property.value.values, i);
}

@@ -23,3 +23,3 @@ break;

for (let i = 0; i < itemCount.count; i++) {
buffer.transformByte(property.value.values, i, toSav);
ar.transformByte(property.value.values, i);
}

@@ -29,3 +29,3 @@ break;

for (let i = 0; i < itemCount.count; i++) {
buffer.transformString(property.value.values, i, toSav);
ar.transformString(property.value.values, i);
}

@@ -35,30 +35,30 @@ break;

for (let i = 0; i < itemCount.count; i++) {
if (!toSav) {
if (ar.isLoading()) {
property.value.values[i] = {};
}
buffer.transformString(property.value.values[i], 'levelName', toSav);
buffer.transformString(property.value.values[i], 'pathName', toSav);
ar.transformString(property.value.values[i], 'levelName');
ar.transformString(property.value.values[i], 'pathName');
}
break;
case 'StructProperty':
buffer.transformString(property, 'structName', toSav);
buffer.transformString(property, 'structType', toSav);
buffer.transformBufferStart(toSav, false);
ar.transformString(property, 'structName');
ar.transformString(property, 'structType');
ar.transformBufferStart(false);
const zero = { zero: 0 };
buffer.transformInt(zero, 'zero', toSav, false);
ar.transformInt(zero, 'zero', false);
if (zero.zero !== 0) {
throw new Error(`Not zero, but ${zero.zero}`);
}
buffer.transformString(property, 'structInnerType', toSav);
buffer.transformHex(property.value, 'unknown', 16, toSav, false);
buffer.transformAssertNullByte(toSav, false);
ar.transformString(property, 'structInnerType');
ar.transformHex(property.value, 'unknown', 16, false);
ar.transformAssertNullByte(false);
// TODO find a better way to make this bidirectional?
if (toSav) {
if (ar.isSaving()) {
for (const prop of property.value.values) {
const obj = prop;
for (const innerProp of obj.properties) {
buffer.transformString(innerProp, 'name', toSav);
Property_1.default(buffer, innerProp, toSav);
ar.transformString(innerProp, 'name'); // Tag.Name
Property_1.default(ar, innerProp);
}
buffer.writeLengthPrefixedString('None'); // end of properties
ar.writeLengthPrefixedString('None'); // end of properties
}

@@ -76,3 +76,3 @@ }

};
buffer.transformString(innerProperty, 'name', toSav);
ar.transformString(innerProperty, 'name'); // Tag.Name
if (innerProperty.name === 'None') {

@@ -83,3 +83,3 @@ break; // end of properties

// console.log('building...',innerProperty.name,j);
Property_1.default(buffer, innerProperty, toSav);
Property_1.default(ar, innerProperty);
props.push(innerProperty);

@@ -92,3 +92,3 @@ }

}
buffer.transformBufferEnd(toSav);
ar.transformBufferEnd();
break;

@@ -95,0 +95,0 @@ default:

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../DataBuffer';
import { Archive } from '../../Archive';
import { Property } from '../../types';
export default function transformBoolProperty(buffer: DataBuffer, property: Property, toSav: boolean): void;
export default function transformBoolProperty(ar: Archive, property: Property): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function transformBoolProperty(buffer, property, toSav) {
buffer.transformByte(property, 'value', toSav, false);
buffer.transformAssertNullByte(toSav, false);
function transformBoolProperty(ar, property) {
ar.transformByte(property, 'value', false); // Tag.BoolVal
ar.transformAssertNullByte(false); // Tag.HasPropertyGuid
}
exports.default = transformBoolProperty;

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../DataBuffer';
import { Archive } from '../../Archive';
import { Property } from '../../types';
export default function transformByteProperty(buffer: DataBuffer, property: Property, toSav: boolean): void;
export default function transformByteProperty(ar: Archive, property: Property): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function transformByteProperty(buffer, property, toSav) {
if (!toSav) {
function transformByteProperty(ar, property) {
if (ar.isLoading()) {
property.value = {};
}
buffer.transformString(property.value, 'unk1', toSav);
buffer.transformAssertNullByte(toSav, false);
if (property.value.unk1 === 'None') {
buffer.transformByte(property.value, 'unk2', toSav);
ar.transformString(property.value, 'enumName'); // Tag.EnumName
ar.transformAssertNullByte(false); // Tag.HasPropertyGuid
if (property.value.enumName === 'None') {
ar.transformByte(property.value, 'value');
}
else {
buffer.transformString(property.value, 'unk2', toSav);
ar.transformString(property.value, 'valueName');
}
}
exports.default = transformByteProperty;

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../DataBuffer';
import { Archive } from '../../Archive';
import { Property } from '../../types';
export default function transformEnumProperty(buffer: DataBuffer, property: Property, toSav: boolean): void;
export default function transformEnumProperty(ar: Archive, property: Property): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function transformEnumProperty(buffer, property, toSav) {
if (!toSav) {
function transformEnumProperty(ar, property) {
if (ar.isLoading()) {
property.value = {};
}
buffer.transformString(property.value, 'enum', toSav, false);
buffer.transformAssertNullByte(toSav, false);
buffer.transformString(property.value, 'value', toSav);
ar.transformString(property.value, 'enum', false); // Tag.EnumName
ar.transformAssertNullByte(false); // Tag.HasPropertyGuid
ar.transformString(property.value, 'value');
}
exports.default = transformEnumProperty;

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../DataBuffer';
import { Archive } from '../../Archive';
import { Property } from '../../types';
export default function transformFloatProperty(buffer: DataBuffer, property: Property, toSav: boolean): void;
export default function transformFloatProperty(ar: Archive, property: Property): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function transformFloatProperty(buffer, property, toSav) {
buffer.transformAssertNullByte(toSav, false);
buffer.transformFloat(property, 'value', toSav);
function transformFloatProperty(ar, property) {
ar.transformAssertNullByte(false); // Tag.HasPropertyGuid
ar.transformFloat(property, 'value');
}
exports.default = transformFloatProperty;

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../DataBuffer';
import { Archive } from '../../Archive';
import { Property } from '../../types';
export default function transformIntProperty(buffer: DataBuffer, property: Property, toSav: boolean): void;
export default function transformIntProperty(ar: Archive, property: Property): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function transformIntProperty(buffer, property, toSav) {
buffer.transformAssertNullByte(toSav, false);
buffer.transformInt(property, 'value', toSav);
function transformIntProperty(ar, property) {
ar.transformAssertNullByte(false); // Tag.HasPropertyGuid
ar.transformInt(property, 'value');
}
exports.default = transformIntProperty;

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../DataBuffer';
import { Archive } from '../../Archive';
import { Property } from '../../types';
export default function transformMapProperty(buffer: DataBuffer, property: Property, toSav: boolean): void;
export default function transformMapProperty(ar: Archive, property: Property): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Property_1 = require("../Property");
function transformMapProperty(buffer, property, toSav) {
if (!toSav) {
function transformMapProperty(ar, property) {
if (ar.isLoading()) {
property.value = {};
}
buffer.transformString(property.value, 'name', toSav, false);
buffer.transformString(property.value, 'type', toSav, false);
buffer.transformAssertNullByte(toSav, false);
ar.transformString(property.value, 'name', false); // Tag.InnerType
ar.transformString(property.value, 'type', false); // Tag.ValueType
ar.transformAssertNullByte(false); // Tag.HasPropertyGuid
const nullInt = { value: 0 };
buffer.transformInt(nullInt, 'value', toSav);
ar.transformInt(nullInt, 'value');
if (nullInt.value !== 0) {

@@ -17,22 +17,23 @@ throw Error(`Not 0, but ${nullInt.value}`);

// TODO find a better way to make this bidirectional?
if (toSav) {
if (ar.isSaving()) {
const sar = ar;
const keys = Object.keys(property.value.values);
buffer.writeInt(keys.length);
sar.writeInt(keys.length);
for (const key of keys) {
// (let [key, value] of property.value.values) {
const value = property.value.values[key];
buffer.writeInt(+key); // parse key to int
sar.writeInt(+key); // parse key to int
for (const element of value) {
buffer.transformString(element, 'name', toSav);
Property_1.default(buffer, element, toSav);
ar.transformString(element, 'name'); // Tag.Name
Property_1.default(ar, element);
}
buffer.writeLengthPrefixedString('None'); // end of properties
sar.writeLengthPrefixedString('None'); // end of properties
}
}
else {
const count = buffer.readInt();
const lar = ar;
const count = lar.readInt();
// console.log('counti', count);
const mapValues = {};
for (let i = 0; i < count; i++) {
const key = buffer.readInt();
const key = lar.readInt();
const props = [];

@@ -46,7 +47,7 @@ while (true) {

};
buffer.transformString(innerProperty, 'name', toSav);
ar.transformString(innerProperty, 'name'); // Tag.Name
if (innerProperty.name === 'None') {
break; // end of properties
}
Property_1.default(buffer, innerProperty, toSav);
Property_1.default(ar, innerProperty);
props.push(innerProperty);

@@ -53,0 +54,0 @@ // console.log('inner', innerProperty);

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../DataBuffer';
import { Archive } from '../../Archive';
import { Property } from '../../types';
export default function transformObjectProperty(buffer: DataBuffer, property: Property, toSav: boolean): void;
export default function transformObjectProperty(ar: Archive, property: Property): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function transformObjectProperty(buffer, property, toSav) {
if (!toSav) {
function transformObjectProperty(ar, property) {
if (ar.isLoading()) {
property.value = {};
}
buffer.transformAssertNullByte(toSav, false);
buffer.transformString(property.value, 'levelName', toSav);
buffer.transformString(property.value, 'pathName', toSav);
ar.transformAssertNullByte(false); // Tag.HasPropertyGuid
ar.transformString(property.value, 'levelName');
ar.transformString(property.value, 'pathName');
}
exports.default = transformObjectProperty;

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../DataBuffer';
import { Archive } from '../../Archive';
import { Property } from '../../types';
export default function transformStringProperty(buffer: DataBuffer, property: Property, toSav: boolean): void;
export default function transformStringProperty(ar: Archive, property: Property): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function transformStringProperty(buffer, property, toSav) {
buffer.transformAssertNullByte(toSav, false);
buffer.transformString(property, 'value', toSav);
function transformStringProperty(ar, property) {
ar.transformAssertNullByte(false); // Tag.HasPropertyGuid
ar.transformString(property, 'value');
}
exports.default = transformStringProperty;

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../DataBuffer';
import { Archive } from '../../Archive';
import { Property } from '../../types';
export default function transformStructProperty(buffer: DataBuffer, property: Property, toSav: boolean): void;
export default function transformStructProperty(ar: Archive, property: Property): void;

@@ -12,10 +12,10 @@ "use strict";

const Box_1 = require("./structs/Box");
function transformStructProperty(buffer, property, toSav) {
if (!toSav) {
function transformStructProperty(ar, property) {
if (ar.isLoading()) {
property.value = {};
}
buffer.transformString(property.value, 'type', toSav);
ar.transformString(property.value, 'type'); // Tag.StructName
const zero = { zero: 0 };
for (let i = 0; i < 4; i++) {
buffer.transformInt(zero, 'zero', toSav, false);
for (let i = 0; i < 4; i++) { // Tag.StructGuid
ar.transformInt(zero, 'zero', false);
if (zero.zero !== 0) {

@@ -25,28 +25,28 @@ throw new Error(`Not zero, but ${zero.zero}`);

}
buffer.transformAssertNullByte(toSav, false);
ar.transformAssertNullByte(false); // Tag.HasPropertyGuid
switch (property.value.type) {
case 'Vector':
case 'Rotator':
Vector_1.transformVector(buffer, property, toSav);
Vector_1.transformVector(ar, property);
break;
case 'Box':
Box_1.transformBox(buffer, property, toSav);
Box_1.transformBox(ar, property);
break;
case 'Color':
Color_1.transformColor(buffer, property, toSav);
Color_1.transformColor(ar, property);
break;
case 'LinearColor':
LinearColor_1.transformLinearColor(buffer, property, toSav);
LinearColor_1.transformLinearColor(ar, property);
break;
case 'Quat':
Quat_1.transformQuat(buffer, property, toSav);
Quat_1.transformQuat(ar, property);
break;
case 'InventoryItem':
IventoryItem_1.transformInventoryItem(buffer, property, toSav);
IventoryItem_1.transformInventoryItem(ar, property);
break;
case 'RailroadTrackPosition':
RailroadTrackPosition_1.transformRailroadTrackPosition(buffer, property, toSav);
RailroadTrackPosition_1.transformRailroadTrackPosition(ar, property);
break;
case 'TimerHandle':
TimerHandle_1.transformTimerHandle(buffer, property, toSav);
TimerHandle_1.transformTimerHandle(ar, property);
break;

@@ -57,3 +57,3 @@ case 'Transform':

case 'ProjectileData':
ArbitraryStruct_1.transformArbitraryStruct(buffer, property, toSav);
ArbitraryStruct_1.transformArbitraryStruct(ar, property);
break;

@@ -60,0 +60,0 @@ default:

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../../DataBuffer';
import { Archive } from '../../../Archive';
import { Property } from '../../../types';
export declare function transformArbitraryStruct(buffer: DataBuffer, property: Property, toSav: boolean): void;
export declare function transformArbitraryStruct(ar: Archive, property: Property): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Property_1 = require("../../Property");
function transformArbitraryStruct(buffer, property, toSav) {
if (toSav) {
function transformArbitraryStruct(ar, property) {
if (ar.isSaving()) {
for (const property2 of property.value.properties) {
buffer.transformString(property2, 'name', toSav);
Property_1.default(buffer, property2, toSav);
ar.transformString(property2, 'name'); // Tag.Name
Property_1.default(ar, property2);
}
buffer.writeLengthPrefixedString('None'); // end of properties
ar.writeLengthPrefixedString('None'); // end of properties
}

@@ -22,7 +22,7 @@ else {

};
buffer.transformString(property2, 'name', toSav);
ar.transformString(property2, 'name'); // Tag.Name
if (property2.name === 'None') {
break; // end of properties
}
Property_1.default(buffer, property2, toSav);
Property_1.default(ar, property2);
property.value.properties.push(property2);

@@ -29,0 +29,0 @@ }

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../../DataBuffer';
import { Archive } from '../../../Archive';
import { Property } from '../../../types';
export declare function transformBox(buffer: DataBuffer, property: Property, toSav: boolean): void;
export declare function transformBox(ar: Archive, property: Property): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function transformBox(buffer, property, toSav) {
if (!toSav) {
function transformBox(ar, property) {
if (ar.isLoading()) {
property.value.min = {};
property.value.max = {};
}
buffer.transformFloat(property.value.min, 0, toSav);
buffer.transformFloat(property.value.min, 1, toSav);
buffer.transformFloat(property.value.min, 2, toSav);
buffer.transformFloat(property.value.max, 0, toSav);
buffer.transformFloat(property.value.max, 1, toSav);
buffer.transformFloat(property.value.max, 2, toSav);
buffer.transformByte(property.value, 'isValid', toSav);
ar.transformFloat(property.value.min, 0);
ar.transformFloat(property.value.min, 1);
ar.transformFloat(property.value.min, 2);
ar.transformFloat(property.value.max, 0);
ar.transformFloat(property.value.max, 1);
ar.transformFloat(property.value.max, 2);
ar.transformByte(property.value, 'isValid');
}
exports.transformBox = transformBox;

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../../DataBuffer';
import { Archive } from '../../../Archive';
import { Property } from '../../../types';
export declare function transformColor(buffer: DataBuffer, property: Property, toSav: boolean): void;
export declare function transformColor(ar: Archive, property: Property): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function transformColor(buffer, property, toSav) {
buffer.transformByte(property.value, 'b', toSav);
buffer.transformByte(property.value, 'g', toSav);
buffer.transformByte(property.value, 'r', toSav);
buffer.transformByte(property.value, 'a', toSav);
function transformColor(ar, property) {
ar.transformByte(property.value, 'b');
ar.transformByte(property.value, 'g');
ar.transformByte(property.value, 'r');
ar.transformByte(property.value, 'a');
}
exports.transformColor = transformColor;

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../../DataBuffer';
import { Archive } from '../../../Archive';
import { Property } from '../../../types';
export declare function transformInventoryItem(buffer: DataBuffer, property: Property, toSav: boolean): void;
export declare function transformInventoryItem(ar: Archive, property: Property): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Property_1 = require("../../Property");
function transformInventoryItem(buffer, property, toSav) {
buffer.transformString(property.value, 'unk1', toSav, false);
buffer.transformString(property.value, 'itemName', toSav);
buffer.transformString(property.value, 'levelName', toSav);
buffer.transformString(property.value, 'pathName', toSav);
if (toSav) {
const oldval = buffer.buffers[buffer.buffers.length - 1]
function transformInventoryItem(ar, property) {
ar.transformString(property.value, 'unk1', false);
ar.transformString(property.value, 'itemName');
ar.transformString(property.value, 'levelName');
ar.transformString(property.value, 'pathName');
if (ar.isSaving()) {
const sar = ar;
const oldval = sar.buffers[sar.buffers.length - 1]
.length;
buffer.transformString(property.value.properties[0], 'name', toSav);
Property_1.default(buffer, property.value.properties[0], toSav);
ar.transformString(property.value.properties[0], 'name'); // Tag.Name
Property_1.default(ar, property.value.properties[0]);
// Dirty hack to make in this one case the inner property
// only take up 4 bytes
buffer.buffers[buffer.buffers.length - 1].length =
sar.buffers[sar.buffers.length - 1].length =
oldval + 4;

@@ -27,7 +28,7 @@ }

};
buffer.transformString(property2, 'name', toSav);
ar.transformString(property2, 'name'); // Tag.Name
if (property2.name === 'None') {
return; // end of properties
}
Property_1.default(buffer, property2, toSav);
Property_1.default(ar, property2);
// can't consume null here because it is needed by the entaingling struct

@@ -34,0 +35,0 @@ props.push(property2);

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../../DataBuffer';
import { Archive } from '../../../Archive';
import { Property } from '../../../types';
export declare function transformLinearColor(buffer: DataBuffer, property: Property, toSav: boolean): void;
export declare function transformLinearColor(ar: Archive, property: Property): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function transformLinearColor(buffer, property, toSav) {
buffer.transformFloat(property.value, 'r', toSav);
buffer.transformFloat(property.value, 'g', toSav);
buffer.transformFloat(property.value, 'b', toSav);
buffer.transformFloat(property.value, 'a', toSav);
function transformLinearColor(ar, property) {
ar.transformFloat(property.value, 'r');
ar.transformFloat(property.value, 'g');
ar.transformFloat(property.value, 'b');
ar.transformFloat(property.value, 'a');
}
exports.transformLinearColor = transformLinearColor;

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../../DataBuffer';
import { Archive } from '../../../Archive';
import { Property } from '../../../types';
export declare function transformQuat(buffer: DataBuffer, property: Property, toSav: boolean): void;
export declare function transformQuat(ar: Archive, property: Property): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function transformQuat(buffer, property, toSav) {
buffer.transformFloat(property.value, 'r', toSav);
buffer.transformFloat(property.value, 'g', toSav);
buffer.transformFloat(property.value, 'b', toSav);
buffer.transformFloat(property.value, 'a', toSav);
function transformQuat(ar, property) {
ar.transformFloat(property.value, 'x');
ar.transformFloat(property.value, 'y');
ar.transformFloat(property.value, 'z');
ar.transformFloat(property.value, 'w');
}
exports.transformQuat = transformQuat;

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../../DataBuffer';
import { Archive } from '../../../Archive';
import { Property } from '../../../types';
export declare function transformRailroadTrackPosition(buffer: DataBuffer, property: Property, toSav: boolean): void;
export declare function transformRailroadTrackPosition(ar: Archive, property: Property): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function transformRailroadTrackPosition(buffer, property, toSav) {
buffer.transformString(property.value, 'levelName', toSav);
buffer.transformString(property.value, 'pathName', toSav);
buffer.transformFloat(property.value, 'offset', toSav);
buffer.transformFloat(property.value, 'forward', toSav);
function transformRailroadTrackPosition(ar, property) {
ar.transformString(property.value, 'levelName');
ar.transformString(property.value, 'pathName');
ar.transformFloat(property.value, 'offset');
ar.transformFloat(property.value, 'forward');
}
exports.transformRailroadTrackPosition = transformRailroadTrackPosition;

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../../DataBuffer';
import { Archive } from '../../../Archive';
import { Property } from '../../../types';
export declare function transformTimerHandle(buffer: DataBuffer, property: Property, toSav: boolean): void;
export declare function transformTimerHandle(ar: Archive, property: Property): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function transformTimerHandle(buffer, property, toSav) {
buffer.transformString(property.value, 'handle', toSav);
function transformTimerHandle(ar, property) {
ar.transformString(property.value, 'handle');
}
exports.transformTimerHandle = transformTimerHandle;

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../../DataBuffer';
import { Archive } from '../../../Archive';
import { Property } from '../../../types';
export declare function transformVector(buffer: DataBuffer, property: Property, toSav: boolean): void;
export declare function transformVector(ar: Archive, property: Property): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function transformVector(buffer, property, toSav) {
buffer.transformFloat(property.value, 'x', toSav);
buffer.transformFloat(property.value, 'y', toSav);
buffer.transformFloat(property.value, 'z', toSav);
function transformVector(ar, property) {
ar.transformFloat(property.value, 'x');
ar.transformFloat(property.value, 'y');
ar.transformFloat(property.value, 'z');
}
exports.transformVector = transformVector;

@@ -1,3 +0,3 @@

import { DataBuffer } from '../../DataBuffer';
import { Archive } from '../../Archive';
import { Property } from '../../types';
export default function transformTextProperty(buffer: DataBuffer, property: Property, toSav: boolean): void;
export default function transformTextProperty(ar: Archive, property: Property): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function transformTextProperty(buffer, property, toSav) {
buffer.transformAssertNullByte(toSav, false);
if (!toSav) {
// ETextHistoryType
const HISTORYTYPE_BASE = 0;
const HISTORYTYPE_NAMEDFORMAT = 1;
const HISTORYTYPE_ORDEREDFORMAT = 2;
const HISTORYTYPE_ARGUMENTFORMAT = 3;
const HISTORYTYPE_ASNUMBER = 4;
const HISTORYTYPE_ASPERCENT = 5;
const HISTORYTYPE_ASCURRENCY = 6;
const HISTORYTYPE_ASDATE = 7;
const HISTORYTYPE_ASTIME = 8;
const HISTORYTYPE_ASDATETIME = 9;
const HISTORYTYPE_TRANSFORM = 10;
const HISTORYTYPE_STRINGTABLEENTRY = 11;
const HISTORYTYPE_NONE = 255; // -1
// EFormatArgumentType
const FORMATARGUMENTTYPE_INT = 0;
const FORMATARGUMENTTYPE_UINT = 1;
const FORMATARGUMENTTYPE_FLOAT = 2;
const FORMATARGUMENTTYPE_DOUBLE = 3;
const FORMATARGUMENTTYPE_TEXT = 4;
const FORMATARGUMENTTYPE_GENDER = 5;
function transformTextProperty(ar, property) {
ar.transformAssertNullByte(false); // Tag.HasPropertyGuid
if (ar.isLoading()) {
property.value = {};
}
buffer.transformInt(property.value, 'unknown1', toSav);
buffer.transformByte(property.value, 'unknown2', toSav);
if (property.value.unknown2 === 0) {
buffer.transformString(property.value, 'unknown3', toSav);
buffer.transformString(property.value, 'unknown4', toSav);
buffer.transformString(property.value, 'text', toSav);
transformFText(ar, property.value);
}
exports.default = transformTextProperty;
function transformFText(ar, value) {
ar.transformInt(value, 'flags'); // Value.Flags
ar.transformByte(value, 'historyType'); // HistoryType
// parse the TextHistory according to TextHistory.cpp
switch (value.historyType) {
case HISTORYTYPE_BASE:
ar.transformString(value, 'namespace');
ar.transformString(value, 'key');
ar.transformString(value, 'sourceString');
break;
case HISTORYTYPE_NONE:
// this is the end of the no value ?
break;
case HISTORYTYPE_ARGUMENTFORMAT:
if (ar.isLoading()) {
value.sourceFmt = {};
}
transformFText(ar, value.sourceFmt);
// Arguments
if (ar.isLoading()) {
value.arguments = [];
}
const argumentCount = { count: value.arguments.length };
ar.transformInt(argumentCount, 'count');
for (let i = 0; i < argumentCount.count; i++) {
if (ar.isLoading()) {
value.arguments[i] = {};
}
ar.transformString(value.arguments[i], 'argumentName');
ar.transformByte(value.arguments[i], 'argumentValueType');
switch (value.arguments[i].argumentValueType) {
case FORMATARGUMENTTYPE_TEXT:
if (ar.isLoading()) {
value.arguments[i].argumentValue = {};
}
transformFText(ar, value.arguments[i].argumentValue);
break;
default:
throw new Error('Unhandled FormatArgumentType: ' +
value.arguments[i].argumentValueType);
}
}
break;
default:
throw new Error('Unhandled HistoryType of TextProperty: ' + value.historyType);
}
else if (property.value.unknown2 === 255) {
// this is the end of the property, no value ?
}
else {
throw new Error('Unknown value for TextProperty unknown2: ' + property.value.unknown2);
}
}
exports.default = transformTextProperty;

@@ -1,3 +0,3 @@

import { DataBuffer } from '../DataBuffer';
import { Archive } from '../Archive';
import { Property } from '../types';
export default function transformProperty(buffer: DataBuffer, property: Property, toSav: boolean): void;
export default function transformProperty(ar: Archive, property: Property): void;

@@ -14,40 +14,41 @@ "use strict";

const StructProperty_1 = require("./properties/StructProperty");
function transformProperty(buffer, property, toSav) {
buffer.transformString(property, 'type', toSav);
buffer.transformBufferStart(toSav, false);
buffer.transformInt(property, 'index', toSav, false);
// compare to FPropertyTag
function transformProperty(ar, property) {
ar.transformString(property, 'type'); // Tag.Type
ar.transformBufferStart(false); // Tag.Size
ar.transformInt(property, 'index', false); // Tag.ArrayIndex
switch (property.type) {
case 'IntProperty':
IntProperty_1.default(buffer, property, toSav);
IntProperty_1.default(ar, property);
break;
case 'BoolProperty':
BoolProperty_1.default(buffer, property, toSav);
BoolProperty_1.default(ar, property);
break;
case 'FloatProperty':
FloatProperty_1.default(buffer, property, toSav);
FloatProperty_1.default(ar, property);
break;
case 'StrProperty':
case 'NameProperty':
StringProperty_1.default(buffer, property, toSav);
StringProperty_1.default(ar, property);
break;
case 'TextProperty':
TextProperty_1.default(buffer, property, toSav);
TextProperty_1.default(ar, property);
break;
case 'ByteProperty':
ByteProperty_1.default(buffer, property, toSav);
ByteProperty_1.default(ar, property);
break;
case 'EnumProperty':
EnumProperty_1.default(buffer, property, toSav);
EnumProperty_1.default(ar, property);
break;
case 'ObjectProperty':
ObjectProperty_1.default(buffer, property, toSav);
ObjectProperty_1.default(ar, property);
break;
case 'StructProperty':
StructProperty_1.default(buffer, property, toSav);
StructProperty_1.default(ar, property);
break;
case 'ArrayProperty':
ArrayProperty_1.default(buffer, property, toSav);
ArrayProperty_1.default(ar, property);
break;
case 'MapProperty':
MapProperty_1.default(buffer, property, toSav);
MapProperty_1.default(ar, property);
break;

@@ -58,5 +59,5 @@ default:

}
buffer.transformBufferEnd(toSav);
ar.transformBufferEnd();
// console.log('property', property);
}
exports.default = transformProperty;
{
"name": "satisfactory-json",
"version": "0.0.17",
"version": "0.0.18",
"description": "Convert Satisfactory save files to JSON and back",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc