satisfactory-json
Advanced tools
Comparing version 0.0.18 to 0.0.19
@@ -10,7 +10,14 @@ /// <reference types="node" /> | ||
isLoading(): boolean; | ||
transformInt(obj: any, key: string | number, count?: boolean): void; | ||
transformString(obj: any, key: string | number, count?: boolean): void; | ||
transformFloat(obj: any, key: string | number): void; | ||
transformLong(obj: any, key: string | number): void; | ||
transformByte(obj: any, key: Key, count?: boolean): void; | ||
transformInt(obj: number, count?: boolean): void; | ||
transformString(obj: string, count?: boolean): void; | ||
transformFloat(obj: number): void; | ||
transformLong(obj: string): void; | ||
transformByte(obj: number, count?: boolean): void; | ||
transformHex(obj: string, count: number, shouldCount?: boolean): void; | ||
_Int(obj: any, key: string | number, count?: boolean): void; | ||
_String(obj: any, key: string | number, count?: boolean): void; | ||
_Float(obj: any, key: string | number): void; | ||
_Long(obj: any, key: string | number): void; | ||
_Byte(obj: any, key: Key, count?: boolean): void; | ||
_Hex(obj: any, key: Key, count: number, shouldCount?: boolean): void; | ||
transformBufferStart(resetBytesRead: boolean): number; | ||
@@ -20,5 +27,27 @@ transformBufferEnd(): void; | ||
transformAssertNullInt(count?: boolean): void; | ||
transformHex(obj: any, key: Key, count: number, shouldCount?: boolean): void; | ||
} | ||
export declare class LoadingArchive implements Archive { | ||
/** | ||
* Base class that implements all the functions that will be removed by the preprocessor | ||
*/ | ||
declare abstract class BaseArchive implements Archive { | ||
abstract isSaving(): boolean; | ||
abstract isLoading(): boolean; | ||
abstract _Int(obj: any, key: string | number, count?: boolean): void; | ||
abstract _String(obj: any, key: string | number, count?: boolean): void; | ||
abstract _Float(obj: any, key: string | number): void; | ||
abstract _Long(obj: any, key: string | number): void; | ||
abstract _Byte(obj: any, key: string | number, count?: boolean): void; | ||
abstract transformBufferStart(resetBytesRead: boolean): number; | ||
abstract transformBufferEnd(): void; | ||
abstract transformAssertNullByte(count?: boolean): void; | ||
abstract transformAssertNullInt(count?: boolean): void; | ||
abstract _Hex(obj: any, key: string | number, count: number, shouldCount?: boolean): void; | ||
transformInt(obj: number, count?: boolean): void; | ||
transformString(obj: string, count?: boolean): void; | ||
transformFloat(obj: number): void; | ||
transformLong(obj: string): void; | ||
transformByte(obj: number, count?: boolean): void; | ||
transformHex(obj: string, count: number, shouldCount?: boolean): void; | ||
} | ||
export declare class LoadingArchive extends BaseArchive { | ||
buffer: Buffer; | ||
@@ -30,7 +59,7 @@ cursor: number; | ||
isLoading(): boolean; | ||
transformInt(obj: any, key: string | number, count?: boolean): void; | ||
transformString(obj: any, key: string | number, count?: boolean): void; | ||
transformFloat(obj: any, key: string | number): void; | ||
transformLong(obj: any, key: string | number): void; | ||
transformByte(obj: any, key: Key, count?: boolean): void; | ||
_Int(obj: any, key: string | number, count?: boolean): void; | ||
_String(obj: any, key: string | number, count?: boolean): void; | ||
_Float(obj: any, key: string | number): void; | ||
_Long(obj: any, key: string | number): void; | ||
_Byte(obj: any, key: Key, count?: boolean): void; | ||
transformBufferStart(resetBytesRead: boolean): number; | ||
@@ -40,3 +69,3 @@ transformBufferEnd(): void; | ||
transformAssertNullInt(count?: boolean): void; | ||
transformHex(obj: any, key: Key, count: number, shouldCount?: boolean): void; | ||
_Hex(obj: any, key: Key, count: number, shouldCount?: boolean): void; | ||
readInt(): number; | ||
@@ -61,3 +90,3 @@ readLong(): string; | ||
*/ | ||
export declare class SavingArchive implements Archive { | ||
export declare class SavingArchive extends BaseArchive { | ||
buffer: Buffer; | ||
@@ -73,7 +102,7 @@ buffers: OutputBufferBuffer[]; | ||
getOutput(): string; | ||
transformInt(obj: any, key: string | number, count?: boolean): void; | ||
transformString(obj: any, key: string | number, count?: boolean): void; | ||
transformFloat(obj: any, key: string | number): void; | ||
transformLong(obj: any, key: string | number): void; | ||
transformByte(obj: any, key: Key, count?: boolean): void; | ||
_Int(obj: any, key: string | number, count?: boolean): void; | ||
_String(obj: any, key: string | number, count?: boolean): void; | ||
_Float(obj: any, key: string | number): void; | ||
_Long(obj: any, key: string | number): void; | ||
_Byte(obj: any, key: Key, count?: boolean): void; | ||
transformBufferStart(resetBytesRead: boolean): number; | ||
@@ -83,3 +112,3 @@ transformBufferEnd(): void; | ||
transformAssertNullInt(count?: boolean): void; | ||
transformHex(obj: any, key: Key, count: number, shouldCount?: boolean): void; | ||
_Hex(obj: any, key: Key, count: number, shouldCount?: boolean): void; | ||
write(bytes: string, count?: boolean): void; | ||
@@ -86,0 +115,0 @@ addBuffer(): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class LoadingArchive { | ||
/** | ||
* Base class that implements all the functions that will be removed by the preprocessor | ||
*/ | ||
class BaseArchive { | ||
transformInt(obj, count) { | ||
throw new Error('transformInt should be removed by preprocessor.'); | ||
} | ||
transformString(obj, count) { | ||
throw new Error('transformString should be removed by preprocessor.'); | ||
} | ||
transformFloat(obj) { | ||
throw new Error('transformFloat should be removed by preprocessor.'); | ||
} | ||
transformLong(obj) { | ||
throw new Error('transformLong should be removed by preprocessor.'); | ||
} | ||
transformByte(obj, count) { | ||
throw new Error('transformByte should be removed by preprocessor.'); | ||
} | ||
transformHex(obj, count, shouldCount) { | ||
throw new Error('transformHex should be removed by preprocessor.'); | ||
} | ||
} | ||
class LoadingArchive extends BaseArchive { | ||
//#endregion | ||
constructor(buffer) { | ||
super(); | ||
this.buffer = buffer; | ||
@@ -16,15 +40,15 @@ this.cursor = 0; | ||
} | ||
transformInt(obj, key, count = true) { | ||
_Int(obj, key, count = true) { | ||
obj[key] = this.readInt(); | ||
} | ||
transformString(obj, key, count = true) { | ||
_String(obj, key, count = true) { | ||
obj[key] = this.readLengthPrefixedString(); | ||
} | ||
transformFloat(obj, key) { | ||
_Float(obj, key) { | ||
obj[key] = this.readFloat(); | ||
} | ||
transformLong(obj, key) { | ||
_Long(obj, key) { | ||
obj[key] = this.readLong(); | ||
} | ||
transformByte(obj, key, count = true) { | ||
_Byte(obj, key, count = true) { | ||
obj[key] = this.readByte(); | ||
@@ -50,3 +74,3 @@ } | ||
} | ||
transformHex(obj, key, count, shouldCount = true) { | ||
_Hex(obj, key, count, shouldCount = true) { | ||
obj[key] = this.readHex(count); | ||
@@ -173,5 +197,6 @@ } | ||
*/ | ||
class SavingArchive { | ||
class SavingArchive extends BaseArchive { | ||
//#endregion | ||
constructor(buffer) { | ||
super(); | ||
//#region write buffer | ||
@@ -194,15 +219,15 @@ this.buffers = []; // TODO make private | ||
} | ||
transformInt(obj, key, count = true) { | ||
_Int(obj, key, count = true) { | ||
this.writeInt(obj[key], count); | ||
} | ||
transformString(obj, key, count = true) { | ||
_String(obj, key, count = true) { | ||
this.writeLengthPrefixedString(obj[key], count); | ||
} | ||
transformFloat(obj, key) { | ||
_Float(obj, key) { | ||
this.writeFloat(obj[key]); | ||
} | ||
transformLong(obj, key) { | ||
_Long(obj, key) { | ||
this.writeLong(obj[key]); | ||
} | ||
transformByte(obj, key, count = true) { | ||
_Byte(obj, key, count = true) { | ||
this.writeByte(obj[key], count); | ||
@@ -223,3 +248,3 @@ } | ||
} | ||
transformHex(obj, key, count, shouldCount = true) { | ||
_Hex(obj, key, count, shouldCount = true) { | ||
this.writeHex(obj[key], shouldCount); | ||
@@ -226,0 +251,0 @@ } |
@@ -33,6 +33,2 @@ "use strict"; | ||
exports.json2sav = json2sav; | ||
/** | ||
* | ||
* @param toSav direction in which to transform. false: sav2json, true: json2sav | ||
*/ | ||
function transform(ar, saveGame) { | ||
@@ -43,7 +39,7 @@ transformHeader(ar, saveGame); | ||
}; | ||
ar.transformInt(entryCount, 'entryCount'); | ||
ar._Int(entryCount, 'entryCount'); | ||
for (let i = 0; i < entryCount.entryCount; i++) { | ||
transformActorOrComponent(ar, saveGame, i); | ||
} | ||
ar.transformInt(entryCount, 'entryCount'); | ||
ar._Int(entryCount, 'entryCount'); | ||
for (let i = 0; i < entryCount.entryCount; i++) { | ||
@@ -62,3 +58,3 @@ if (i < saveGame.actors.length) { | ||
}; | ||
ar.transformInt(collectedCount, 'count'); | ||
ar._Int(collectedCount, 'count'); | ||
for (let i = 0; i < collectedCount.count; i++) { | ||
@@ -68,18 +64,18 @@ if (ar.isLoading()) { | ||
} | ||
ar.transformString(saveGame.collected[i], 'levelName'); | ||
ar.transformString(saveGame.collected[i], 'pathName'); | ||
ar._String(saveGame.collected[i], 'levelName'); | ||
ar._String(saveGame.collected[i], 'pathName'); | ||
} | ||
// TODO missing | ||
} | ||
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'); | ||
function transformHeader(ar, saveGame) { | ||
ar._Int(saveGame, 'saveHeaderType'); | ||
ar._Int(saveGame, 'saveVersion'); | ||
ar._Int(saveGame, 'buildVersion'); | ||
ar._String(saveGame, 'mapName'); | ||
ar._String(saveGame, 'mapOptions'); | ||
ar._String(saveGame, 'sessionName'); | ||
ar._Int(saveGame, 'playDurationSeconds'); | ||
ar._Long(saveGame, 'saveDateTime'); | ||
if (saveGame.saveHeaderType > 4) { | ||
buffer.transformByte(saveGame, 'sessionVisibility'); | ||
ar._Byte(saveGame, 'sessionVisibility'); | ||
} | ||
@@ -89,3 +85,3 @@ } | ||
const type = { type: id < saveGame.actors.length ? 1 : 0 }; | ||
ar.transformInt(type, 'type'); | ||
ar._Int(type, 'type'); | ||
if (ar.isLoading()) { | ||
@@ -92,0 +88,0 @@ if (type.type === 1) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function transformActor(ar, actor) { | ||
ar.transformString(actor, 'className'); | ||
ar.transformString(actor, 'levelName'); | ||
ar.transformString(actor, 'pathName'); | ||
ar.transformInt(actor, 'needTransform'); | ||
ar.transformFloat(actor.transform.rotation, 0); | ||
ar.transformFloat(actor.transform.rotation, 1); | ||
ar.transformFloat(actor.transform.rotation, 2); | ||
ar.transformFloat(actor.transform.rotation, 3); | ||
ar.transformFloat(actor.transform.translation, 0); | ||
ar.transformFloat(actor.transform.translation, 1); | ||
ar.transformFloat(actor.transform.translation, 2); | ||
ar.transformFloat(actor.transform.scale3d, 0); | ||
ar.transformFloat(actor.transform.scale3d, 1); | ||
ar.transformFloat(actor.transform.scale3d, 2); | ||
ar.transformInt(actor, 'wasPlacedInLevel'); | ||
ar._String(actor, 'className'); | ||
ar._String(actor, 'levelName'); | ||
ar._String(actor, 'pathName'); | ||
ar._Int(actor, 'needTransform'); | ||
ar._Float(actor.transform.rotation, 0); | ||
ar._Float(actor.transform.rotation, 1); | ||
ar._Float(actor.transform.rotation, 2); | ||
ar._Float(actor.transform.rotation, 3); | ||
ar._Float(actor.transform.translation, 0); | ||
ar._Float(actor.transform.translation, 1); | ||
ar._Float(actor.transform.translation, 2); | ||
ar._Float(actor.transform.scale3d, 0); | ||
ar._Float(actor.transform.scale3d, 1); | ||
ar._Float(actor.transform.scale3d, 2); | ||
ar._Int(actor, 'wasPlacedInLevel'); | ||
} | ||
exports.default = transformActor; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function transformComponent(ar, component) { | ||
ar.transformString(component, 'className'); | ||
ar.transformString(component, 'levelName'); | ||
ar.transformString(component, 'pathName'); | ||
ar.transformString(component, 'outerPathName'); | ||
ar._String(component, 'className'); | ||
ar._String(component, 'levelName'); | ||
ar._String(component, 'pathName'); | ||
ar._String(component, 'outerPathName'); | ||
} | ||
exports.default = transformComponent; |
@@ -8,6 +8,6 @@ "use strict"; | ||
if (withNames) { | ||
ar.transformString(entity, 'levelName'); | ||
ar.transformString(entity, 'pathName'); | ||
ar._String(entity, 'levelName'); | ||
ar._String(entity, 'pathName'); | ||
const childCount = { count: entity.children.length }; | ||
ar.transformInt(childCount, 'count'); | ||
ar._Int(childCount, 'count'); | ||
for (let i = 0; i < childCount.count; i++) { | ||
@@ -17,4 +17,4 @@ if (ar.isLoading()) { | ||
} | ||
ar.transformString(entity.children[i], 'levelName'); | ||
ar.transformString(entity.children[i], 'pathName'); | ||
ar._String(entity.children[i], 'levelName'); | ||
ar._String(entity.children[i], 'pathName'); | ||
} | ||
@@ -24,3 +24,3 @@ } | ||
const extraObjectCount = { count: 0 }; | ||
ar.transformInt(extraObjectCount, 'count'); | ||
ar._Int(extraObjectCount, 'count'); | ||
if (extraObjectCount.count !== 0) { | ||
@@ -59,3 +59,3 @@ throw Error(`Extra object count not zero, but ${extraObjectCount.count}`); | ||
for (const property of entity.properties) { | ||
ar.transformString(property, 'name'); // Tag.Name | ||
ar._String(property, 'name'); // Tag.Name | ||
Property_1.default(ar, property); | ||
@@ -74,3 +74,3 @@ } | ||
}; | ||
ar.transformString(property, 'name'); // Tag.Name | ||
ar._String(property, 'name'); // Tag.Name | ||
if (property.name === 'None') { | ||
@@ -77,0 +77,0 @@ break; // end of properties |
@@ -10,3 +10,3 @@ "use strict"; | ||
const circuits = { length: entity.extra.circuits.length }; | ||
ar.transformInt(circuits, 'length'); | ||
ar._Int(circuits, 'length'); | ||
for (let i = 0; i < circuits.length; i++) { | ||
@@ -16,7 +16,7 @@ if (ar.isLoading()) { | ||
} | ||
ar.transformInt(entity.extra.circuits[i], 'circuitId'); | ||
ar.transformString(entity.extra.circuits[i], 'levelName'); | ||
ar.transformString(entity.extra.circuits[i], 'pathName'); | ||
ar._Int(entity.extra.circuits[i], 'circuitId'); | ||
ar._String(entity.extra.circuits[i], 'levelName'); | ||
ar._String(entity.extra.circuits[i], 'pathName'); | ||
} | ||
} | ||
exports.default = transformCircuitSubsystem; |
@@ -10,3 +10,3 @@ "use strict"; | ||
const items = { length: entity.extra.items.length }; | ||
ar.transformInt(items, 'length'); | ||
ar._Int(items, 'length'); | ||
for (let i = 0; i < items.length; i++) { | ||
@@ -22,8 +22,8 @@ if (ar.isLoading()) { | ||
ar.transformAssertNullInt(); | ||
ar.transformString(entity.extra.items[i], 'name'); | ||
ar._String(entity.extra.items[i], 'name'); | ||
ar.transformAssertNullInt(); | ||
ar.transformAssertNullInt(); | ||
ar.transformFloat(entity.extra.items[i], 'position'); | ||
ar._Float(entity.extra.items[i], 'position'); | ||
} | ||
} | ||
exports.default = transformConveyorBelt; |
@@ -10,3 +10,3 @@ "use strict"; | ||
const objects = { length: entity.extra.objects.length }; | ||
ar.transformInt(objects, 'length'); | ||
ar._Int(objects, 'length'); | ||
for (let i = 0; i < objects.length; i++) { | ||
@@ -16,6 +16,6 @@ if (ar.isLoading()) { | ||
} | ||
ar.transformString(entity.extra.objects[i], 'levelName'); | ||
ar.transformString(entity.extra.objects[i], 'pathName'); | ||
ar._String(entity.extra.objects[i], 'levelName'); | ||
ar._String(entity.extra.objects[i], 'pathName'); | ||
} | ||
} | ||
exports.default = transformGameMode; |
@@ -10,3 +10,3 @@ "use strict"; | ||
const objects = { length: entity.extra.objects.length }; | ||
ar.transformInt(objects, 'length'); | ||
ar._Int(objects, 'length'); | ||
for (let i = 0; i < objects.length; i++) { | ||
@@ -16,6 +16,6 @@ if (ar.isLoading()) { | ||
} | ||
ar.transformString(entity.extra.objects[i], 'levelName'); | ||
ar.transformString(entity.extra.objects[i], 'pathName'); | ||
ar._String(entity.extra.objects[i], 'levelName'); | ||
ar._String(entity.extra.objects[i], 'pathName'); | ||
} | ||
} | ||
exports.default = transformGameState; |
@@ -12,4 +12,4 @@ "use strict"; | ||
} | ||
ar.transformHex(entity.extra, 'unknown', count); | ||
ar._Hex(entity.extra, 'unknown', count); | ||
} | ||
exports.default = transformPlayerState; |
@@ -7,7 +7,7 @@ "use strict"; | ||
} | ||
ar.transformString(entity.extra, 'sourceLevelName'); | ||
ar.transformString(entity.extra, 'sourcePathName'); | ||
ar.transformString(entity.extra, 'targetLevelName'); | ||
ar.transformString(entity.extra, 'targetPathName'); | ||
ar._String(entity.extra, 'sourceLevelName'); | ||
ar._String(entity.extra, 'sourcePathName'); | ||
ar._String(entity.extra, 'targetLevelName'); | ||
ar._String(entity.extra, 'targetPathName'); | ||
} | ||
exports.default = transformPowerLine; |
@@ -21,3 +21,3 @@ "use strict"; | ||
const trains = { length: entity.extra.trains.length }; | ||
ar.transformInt(trains, 'length'); | ||
ar._Int(trains, 'length'); | ||
for (let i = 0; i < trains.length; i++) { | ||
@@ -27,11 +27,11 @@ if (ar.isLoading()) { | ||
} | ||
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'); | ||
ar._Hex(entity.extra.trains[i], 'unknown', 4); | ||
ar._String(entity.extra.trains[i], 'firstLevelName'); | ||
ar._String(entity.extra.trains[i], 'firstPathName'); | ||
ar._String(entity.extra.trains[i], 'secondLevelName'); | ||
ar._String(entity.extra.trains[i], 'secondPathName'); | ||
ar._String(entity.extra.trains[i], 'timetableLevelName'); | ||
ar._String(entity.extra.trains[i], 'timetablePathName'); | ||
} | ||
} | ||
exports.default = transformRailroadSubsystem; |
@@ -8,7 +8,7 @@ "use strict"; | ||
ar.transformAssertNullInt(); | ||
ar.transformString(entity.extra, 'previousLevelName'); | ||
ar.transformString(entity.extra, 'previousPathName'); | ||
ar.transformString(entity.extra, 'nextLevelName'); | ||
ar.transformString(entity.extra, 'nextPathName'); | ||
ar._String(entity.extra, 'previousLevelName'); | ||
ar._String(entity.extra, 'previousPathName'); | ||
ar._String(entity.extra, 'nextLevelName'); | ||
ar._String(entity.extra, 'nextPathName'); | ||
} | ||
exports.default = transformTrain; |
@@ -10,3 +10,3 @@ "use strict"; | ||
const objects = { length: entity.extra.objects.length }; | ||
ar.transformInt(objects, 'length'); | ||
ar._Int(objects, 'length'); | ||
for (let i = 0; i < objects.length; i++) { | ||
@@ -16,6 +16,6 @@ if (ar.isLoading()) { | ||
} | ||
ar.transformString(entity.extra.objects[i], 'name'); | ||
ar.transformHex(entity.extra.objects[i], 'unknown', 53); | ||
ar._String(entity.extra.objects[i], 'name'); | ||
ar._Hex(entity.extra.objects[i], 'unknown', 53); | ||
} | ||
} | ||
exports.default = transformVehicle; |
import { Archive } from '../../Archive'; | ||
import { Property } from '../../types'; | ||
export default function transformArrayProperty(ar: Archive, property: Property): void; | ||
import { ArrayProperty } from '../../types'; | ||
export default function transformArrayProperty(ar: Archive, property: ArrayProperty): void; |
@@ -10,10 +10,10 @@ "use strict"; | ||
} | ||
ar.transformString(property.value, 'type', false); // Tag.InnerType | ||
ar._String(property.value, 'type', false); // Tag.InnerType | ||
ar.transformAssertNullByte(false); // Tag.HasPropertyGuid | ||
const itemCount = { count: property.value.values.length }; | ||
ar.transformInt(itemCount, 'count'); | ||
ar._Int(itemCount, 'count'); | ||
switch (property.value.type) { | ||
case 'IntProperty': | ||
for (let i = 0; i < itemCount.count; i++) { | ||
ar.transformInt(property.value.values, i); | ||
ar._Int(property.value.values, i); | ||
} | ||
@@ -23,3 +23,3 @@ break; | ||
for (let i = 0; i < itemCount.count; i++) { | ||
ar.transformByte(property.value.values, i); | ||
ar._Byte(property.value.values, i); | ||
} | ||
@@ -29,3 +29,3 @@ break; | ||
for (let i = 0; i < itemCount.count; i++) { | ||
ar.transformString(property.value.values, i); | ||
ar._String(property.value.values, i); | ||
} | ||
@@ -38,17 +38,17 @@ break; | ||
} | ||
ar.transformString(property.value.values[i], 'levelName'); | ||
ar.transformString(property.value.values[i], 'pathName'); | ||
ar._String(property.value.values[i], 'levelName'); | ||
ar._String(property.value.values[i], 'pathName'); | ||
} | ||
break; | ||
case 'StructProperty': | ||
ar.transformString(property, 'structName'); | ||
ar.transformString(property, 'structType'); | ||
ar._String(property.value, 'structName'); | ||
ar._String(property.value, 'structType'); | ||
ar.transformBufferStart(false); | ||
const zero = { zero: 0 }; | ||
ar.transformInt(zero, 'zero', false); | ||
ar._Int(zero, 'zero', false); | ||
if (zero.zero !== 0) { | ||
throw new Error(`Not zero, but ${zero.zero}`); | ||
} | ||
ar.transformString(property, 'structInnerType'); | ||
ar.transformHex(property.value, 'unknown', 16, false); | ||
ar._String(property.value, 'structInnerType'); | ||
ar._Hex(property.value, 'propertyGuid', 16, false); | ||
ar.transformAssertNullByte(false); | ||
@@ -60,3 +60,3 @@ // TODO find a better way to make this bidirectional? | ||
for (const innerProp of obj.properties) { | ||
ar.transformString(innerProp, 'name'); // Tag.Name | ||
ar._String(innerProp, 'name'); // Tag.Name | ||
Property_1.default(ar, innerProp); | ||
@@ -77,3 +77,3 @@ } | ||
}; | ||
ar.transformString(innerProperty, 'name'); // Tag.Name | ||
ar._String(innerProperty, 'name'); // Tag.Name | ||
if (innerProperty.name === 'None') { | ||
@@ -80,0 +80,0 @@ break; // end of properties |
import { Archive } from '../../Archive'; | ||
import { Property } from '../../types'; | ||
export default function transformBoolProperty(ar: Archive, property: Property): void; | ||
import { BoolProperty } from '../../types'; | ||
export default function transformBoolProperty(ar: Archive, property: BoolProperty): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function transformBoolProperty(ar, property) { | ||
ar.transformByte(property, 'value', false); // Tag.BoolVal | ||
ar._Byte(property, 'value', false); // Tag.BoolVal | ||
ar.transformAssertNullByte(false); // Tag.HasPropertyGuid | ||
} | ||
exports.default = transformBoolProperty; |
import { Archive } from '../../Archive'; | ||
import { Property } from '../../types'; | ||
export default function transformByteProperty(ar: Archive, property: Property): void; | ||
import { ByteProperty } from '../../types'; | ||
export default function transformByteProperty(ar: Archive, property: ByteProperty): void; |
@@ -5,13 +5,15 @@ "use strict"; | ||
if (ar.isLoading()) { | ||
property.value = {}; | ||
property.value = { | ||
enumName: '' | ||
}; | ||
} | ||
ar.transformString(property.value, 'enumName'); // Tag.EnumName | ||
ar._String(property.value, 'enumName'); // Tag.EnumName | ||
ar.transformAssertNullByte(false); // Tag.HasPropertyGuid | ||
if (property.value.enumName === 'None') { | ||
ar.transformByte(property.value, 'value'); | ||
ar._Byte(property.value, 'value'); | ||
} | ||
else { | ||
ar.transformString(property.value, 'valueName'); | ||
ar._String(property.value, 'valueName'); | ||
} | ||
} | ||
exports.default = transformByteProperty; |
import { Archive } from '../../Archive'; | ||
import { Property } from '../../types'; | ||
export default function transformEnumProperty(ar: Archive, property: Property): void; | ||
import { EnumProperty } from '../../types'; | ||
export default function transformEnumProperty(ar: Archive, property: EnumProperty): void; |
@@ -5,8 +5,11 @@ "use strict"; | ||
if (ar.isLoading()) { | ||
property.value = {}; | ||
property.value = { | ||
enum: '', | ||
value: '' | ||
}; | ||
} | ||
ar.transformString(property.value, 'enum', false); // Tag.EnumName | ||
ar._String(property.value, 'enum', false); // Tag.EnumName | ||
ar.transformAssertNullByte(false); // Tag.HasPropertyGuid | ||
ar.transformString(property.value, 'value'); | ||
ar._String(property.value, 'value'); | ||
} | ||
exports.default = transformEnumProperty; |
import { Archive } from '../../Archive'; | ||
import { Property } from '../../types'; | ||
export default function transformFloatProperty(ar: Archive, property: Property): void; | ||
import { FloatProperty } from '../../types'; | ||
export default function transformFloatProperty(ar: Archive, property: FloatProperty): void; |
@@ -5,4 +5,4 @@ "use strict"; | ||
ar.transformAssertNullByte(false); // Tag.HasPropertyGuid | ||
ar.transformFloat(property, 'value'); | ||
ar._Float(property, 'value'); | ||
} | ||
exports.default = transformFloatProperty; |
import { Archive } from '../../Archive'; | ||
import { Property } from '../../types'; | ||
export default function transformIntProperty(ar: Archive, property: Property): void; | ||
import { IntProperty } from '../../types'; | ||
export default function transformIntProperty(ar: Archive, property: IntProperty): void; |
@@ -5,4 +5,4 @@ "use strict"; | ||
ar.transformAssertNullByte(false); // Tag.HasPropertyGuid | ||
ar.transformInt(property, 'value'); | ||
ar._Int(property, 'value'); | ||
} | ||
exports.default = transformIntProperty; |
import { Archive } from '../../Archive'; | ||
import { Property } from '../../types'; | ||
export default function transformMapProperty(ar: Archive, property: Property): void; | ||
import { MapProperty } from '../../types'; | ||
export default function transformMapProperty(ar: Archive, property: MapProperty): void; |
@@ -8,7 +8,7 @@ "use strict"; | ||
} | ||
ar.transformString(property.value, 'name', false); // Tag.InnerType | ||
ar.transformString(property.value, 'type', false); // Tag.ValueType | ||
ar._String(property.value, 'name', false); // Tag.InnerType | ||
ar._String(property.value, 'type', false); // Tag.ValueType | ||
ar.transformAssertNullByte(false); // Tag.HasPropertyGuid | ||
const nullInt = { value: 0 }; | ||
ar.transformInt(nullInt, 'value'); | ||
ar._Int(nullInt, 'value'); | ||
if (nullInt.value !== 0) { | ||
@@ -26,3 +26,3 @@ throw Error(`Not 0, but ${nullInt.value}`); | ||
for (const element of value) { | ||
ar.transformString(element, 'name'); // Tag.Name | ||
ar._String(element, 'name'); // Tag.Name | ||
Property_1.default(ar, element); | ||
@@ -48,3 +48,3 @@ } | ||
}; | ||
ar.transformString(innerProperty, 'name'); // Tag.Name | ||
ar._String(innerProperty, 'name'); // Tag.Name | ||
if (innerProperty.name === 'None') { | ||
@@ -51,0 +51,0 @@ break; // end of properties |
import { Archive } from '../../Archive'; | ||
import { Property } from '../../types'; | ||
export default function transformObjectProperty(ar: Archive, property: Property): void; | ||
import { ObjectProperty } from '../../types'; | ||
export default function transformObjectProperty(ar: Archive, property: ObjectProperty): void; |
@@ -5,8 +5,11 @@ "use strict"; | ||
if (ar.isLoading()) { | ||
property.value = {}; | ||
property.value = { | ||
levelName: '', | ||
pathName: '' | ||
}; | ||
} | ||
ar.transformAssertNullByte(false); // Tag.HasPropertyGuid | ||
ar.transformString(property.value, 'levelName'); | ||
ar.transformString(property.value, 'pathName'); | ||
ar._String(property.value, 'levelName'); | ||
ar._String(property.value, 'pathName'); | ||
} | ||
exports.default = transformObjectProperty; |
import { Archive } from '../../Archive'; | ||
import { Property } from '../../types'; | ||
export default function transformStringProperty(ar: Archive, property: Property): void; | ||
import { StringProperty } from '../../types'; | ||
export default function transformStringProperty(ar: Archive, property: StringProperty): void; |
@@ -5,4 +5,4 @@ "use strict"; | ||
ar.transformAssertNullByte(false); // Tag.HasPropertyGuid | ||
ar.transformString(property, 'value'); | ||
ar._String(property, 'value'); | ||
} | ||
exports.default = transformStringProperty; |
import { Archive } from '../../Archive'; | ||
import { Property } from '../../types'; | ||
export default function transformStructProperty(ar: Archive, property: Property): void; | ||
import { StructProperty } from '../../types'; | ||
export default function transformStructProperty(ar: Archive, property: StructProperty): void; |
@@ -16,6 +16,6 @@ "use strict"; | ||
} | ||
ar.transformString(property.value, 'type'); // Tag.StructName | ||
ar._String(property.value, 'type'); // Tag.StructName | ||
const zero = { zero: 0 }; | ||
for (let i = 0; i < 4; i++) { // Tag.StructGuid | ||
ar.transformInt(zero, 'zero', false); | ||
ar._Int(zero, 'zero', false); | ||
if (zero.zero !== 0) { | ||
@@ -22,0 +22,0 @@ throw new Error(`Not zero, but ${zero.zero}`); |
import { Archive } from '../../../Archive'; | ||
import { Property } from '../../../types'; | ||
export declare function transformArbitraryStruct(ar: Archive, property: Property): void; | ||
import { StructProperty } from '../../../types'; | ||
export declare function transformArbitraryStruct(ar: Archive, property: StructProperty): void; |
@@ -7,3 +7,3 @@ "use strict"; | ||
for (const property2 of property.value.properties) { | ||
ar.transformString(property2, 'name'); // Tag.Name | ||
ar._String(property2, 'name'); // Tag.Name | ||
Property_1.default(ar, property2); | ||
@@ -23,3 +23,3 @@ } | ||
}; | ||
ar.transformString(property2, 'name'); // Tag.Name | ||
ar._String(property2, 'name'); // Tag.Name | ||
if (property2.name === 'None') { | ||
@@ -26,0 +26,0 @@ break; // end of properties |
import { Archive } from '../../../Archive'; | ||
import { Property } from '../../../types'; | ||
export declare function transformBox(ar: Archive, property: Property): void; | ||
import { StructProperty } from '../../../types'; | ||
export declare function transformBox(ar: Archive, property: StructProperty): void; |
@@ -8,10 +8,10 @@ "use strict"; | ||
} | ||
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'); | ||
ar._Float(property.value.min, 0); | ||
ar._Float(property.value.min, 1); | ||
ar._Float(property.value.min, 2); | ||
ar._Float(property.value.max, 0); | ||
ar._Float(property.value.max, 1); | ||
ar._Float(property.value.max, 2); | ||
ar._Byte(property.value, 'isValid'); | ||
} | ||
exports.transformBox = transformBox; |
import { Archive } from '../../../Archive'; | ||
import { Property } from '../../../types'; | ||
export declare function transformColor(ar: Archive, property: Property): void; | ||
import { StructProperty } from '../../../types'; | ||
export declare function transformColor(ar: Archive, property: StructProperty): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function transformColor(ar, property) { | ||
ar.transformByte(property.value, 'b'); | ||
ar.transformByte(property.value, 'g'); | ||
ar.transformByte(property.value, 'r'); | ||
ar.transformByte(property.value, 'a'); | ||
ar._Byte(property.value, 'b'); | ||
ar._Byte(property.value, 'g'); | ||
ar._Byte(property.value, 'r'); | ||
ar._Byte(property.value, 'a'); | ||
} | ||
exports.transformColor = transformColor; |
import { Archive } from '../../../Archive'; | ||
import { Property } from '../../../types'; | ||
export declare function transformInventoryItem(ar: Archive, property: Property): void; | ||
import { StructProperty } from '../../../types'; | ||
export declare function transformInventoryItem(ar: Archive, property: StructProperty): void; |
@@ -5,6 +5,6 @@ "use strict"; | ||
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'); | ||
ar._String(property.value, 'unk1', false); | ||
ar._String(property.value, 'itemName'); | ||
ar._String(property.value, 'levelName'); | ||
ar._String(property.value, 'pathName'); | ||
if (ar.isSaving()) { | ||
@@ -14,3 +14,3 @@ const sar = ar; | ||
.length; | ||
ar.transformString(property.value.properties[0], 'name'); // Tag.Name | ||
ar._String(property.value.properties[0], 'name'); // Tag.Name | ||
Property_1.default(ar, property.value.properties[0]); | ||
@@ -30,3 +30,3 @@ // Dirty hack to make in this one case the inner property | ||
}; | ||
ar.transformString(property2, 'name'); // Tag.Name | ||
ar._String(property2, 'name'); // Tag.Name | ||
if (property2.name === 'None') { | ||
@@ -33,0 +33,0 @@ return; // end of properties |
import { Archive } from '../../../Archive'; | ||
import { Property } from '../../../types'; | ||
export declare function transformLinearColor(ar: Archive, property: Property): void; | ||
import { StructProperty } from '../../../types'; | ||
export declare function transformLinearColor(ar: Archive, property: StructProperty): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function transformLinearColor(ar, property) { | ||
ar.transformFloat(property.value, 'r'); | ||
ar.transformFloat(property.value, 'g'); | ||
ar.transformFloat(property.value, 'b'); | ||
ar.transformFloat(property.value, 'a'); | ||
ar._Float(property.value, 'r'); | ||
ar._Float(property.value, 'g'); | ||
ar._Float(property.value, 'b'); | ||
ar._Float(property.value, 'a'); | ||
} | ||
exports.transformLinearColor = transformLinearColor; |
import { Archive } from '../../../Archive'; | ||
import { Property } from '../../../types'; | ||
export declare function transformQuat(ar: Archive, property: Property): void; | ||
import { StructProperty } from '../../../types'; | ||
export declare function transformQuat(ar: Archive, property: StructProperty): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function transformQuat(ar, property) { | ||
ar.transformFloat(property.value, 'x'); | ||
ar.transformFloat(property.value, 'y'); | ||
ar.transformFloat(property.value, 'z'); | ||
ar.transformFloat(property.value, 'w'); | ||
ar._Float(property.value, 'x'); | ||
ar._Float(property.value, 'y'); | ||
ar._Float(property.value, 'z'); | ||
ar._Float(property.value, 'w'); | ||
} | ||
exports.transformQuat = transformQuat; |
import { Archive } from '../../../Archive'; | ||
import { Property } from '../../../types'; | ||
export declare function transformRailroadTrackPosition(ar: Archive, property: Property): void; | ||
import { StructProperty } from '../../../types'; | ||
export declare function transformRailroadTrackPosition(ar: Archive, property: StructProperty): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function transformRailroadTrackPosition(ar, property) { | ||
ar.transformString(property.value, 'levelName'); | ||
ar.transformString(property.value, 'pathName'); | ||
ar.transformFloat(property.value, 'offset'); | ||
ar.transformFloat(property.value, 'forward'); | ||
ar._String(property.value, 'levelName'); | ||
ar._String(property.value, 'pathName'); | ||
ar._Float(property.value, 'offset'); | ||
ar._Float(property.value, 'forward'); | ||
} | ||
exports.transformRailroadTrackPosition = transformRailroadTrackPosition; |
import { Archive } from '../../../Archive'; | ||
import { Property } from '../../../types'; | ||
export declare function transformTimerHandle(ar: Archive, property: Property): void; | ||
import { StructProperty } from '../../../types'; | ||
export declare function transformTimerHandle(ar: Archive, property: StructProperty): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function transformTimerHandle(ar, property) { | ||
ar.transformString(property.value, 'handle'); | ||
ar._String(property.value, 'handle'); | ||
} | ||
exports.transformTimerHandle = transformTimerHandle; |
import { Archive } from '../../../Archive'; | ||
import { Property } from '../../../types'; | ||
export declare function transformVector(ar: Archive, property: Property): void; | ||
import { StructProperty } from '../../../types'; | ||
export declare function transformVector(ar: Archive, property: StructProperty): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function transformVector(ar, property) { | ||
ar.transformFloat(property.value, 'x'); | ||
ar.transformFloat(property.value, 'y'); | ||
ar.transformFloat(property.value, 'z'); | ||
ar._Float(property.value, 'x'); | ||
ar._Float(property.value, 'y'); | ||
ar._Float(property.value, 'z'); | ||
} | ||
exports.transformVector = transformVector; |
import { Archive } from '../../Archive'; | ||
import { Property } from '../../types'; | ||
export default function transformTextProperty(ar: Archive, property: Property): void; | ||
import { TextProperty } from '../../types'; | ||
export default function transformTextProperty(ar: Archive, property: TextProperty): void; |
@@ -27,3 +27,6 @@ "use strict"; | ||
if (ar.isLoading()) { | ||
property.value = {}; | ||
property.value = { | ||
flags: 0, | ||
historyType: 0 | ||
}; | ||
} | ||
@@ -34,10 +37,10 @@ transformFText(ar, property.value); | ||
function transformFText(ar, value) { | ||
ar.transformInt(value, 'flags'); // Value.Flags | ||
ar.transformByte(value, 'historyType'); // HistoryType | ||
ar._Int(value, 'flags'); // Value.Flags | ||
ar._Byte(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'); | ||
ar._String(value, 'namespace'); | ||
ar._String(value, 'key'); | ||
ar._String(value, 'sourceString'); | ||
break; | ||
@@ -49,3 +52,6 @@ case HISTORYTYPE_NONE: | ||
if (ar.isLoading()) { | ||
value.sourceFmt = {}; | ||
value.sourceFmt = { | ||
flags: 0, | ||
historyType: 0 | ||
}; | ||
} | ||
@@ -58,13 +64,19 @@ transformFText(ar, value.sourceFmt); | ||
const argumentCount = { count: value.arguments.length }; | ||
ar.transformInt(argumentCount, 'count'); | ||
ar._Int(argumentCount, 'count'); | ||
for (let i = 0; i < argumentCount.count; i++) { | ||
if (ar.isLoading()) { | ||
value.arguments[i] = {}; | ||
value.arguments[i] = { | ||
argumentName: '', | ||
argumentValueType: 0 | ||
}; | ||
} | ||
ar.transformString(value.arguments[i], 'argumentName'); | ||
ar.transformByte(value.arguments[i], 'argumentValueType'); | ||
ar._String(value.arguments[i], 'argumentName'); | ||
ar._Byte(value.arguments[i], 'argumentValueType'); | ||
switch (value.arguments[i].argumentValueType) { | ||
case FORMATARGUMENTTYPE_TEXT: | ||
if (ar.isLoading()) { | ||
value.arguments[i].argumentValue = {}; | ||
value.arguments[i].argumentValue = { | ||
flags: 0, | ||
historyType: 0 | ||
}; | ||
} | ||
@@ -71,0 +83,0 @@ transformFText(ar, value.arguments[i].argumentValue); |
@@ -16,5 +16,5 @@ "use strict"; | ||
function transformProperty(ar, property) { | ||
ar.transformString(property, 'type'); // Tag.Type | ||
ar._String(property, 'type'); // Tag.Type | ||
ar.transformBufferStart(false); // Tag.Size | ||
ar.transformInt(property, 'index', false); // Tag.ArrayIndex | ||
ar._Int(property, 'index', false); // Tag.ArrayIndex | ||
switch (property.type) { | ||
@@ -56,8 +56,6 @@ case 'IntProperty': | ||
default: | ||
// console.log(buffer.readHex(32)); | ||
throw Error(`Unkown property type ${property.type}`); | ||
} | ||
ar.transformBufferEnd(); | ||
// console.log('property', property); | ||
} | ||
exports.default = transformProperty; |
@@ -64,3 +64,3 @@ export interface SaveGame { | ||
} | ||
export interface StrProperty extends BaseProperty { | ||
export interface StringProperty extends BaseProperty { | ||
value: string; | ||
@@ -72,17 +72,30 @@ } | ||
export interface TextProperty extends BaseProperty { | ||
unknown1: number; | ||
unknown2: number; | ||
unknown3: number; | ||
unknown4: string; | ||
value: string; | ||
value: FText; | ||
} | ||
export interface FText { | ||
flags: number; | ||
historyType: number; | ||
namespace?: string; | ||
key?: string; | ||
sourceString?: string; | ||
sourceFmt?: FText; | ||
arguments?: TextArgument[]; | ||
} | ||
export interface TextArgument { | ||
argumentName: string; | ||
argumentValueType: number; | ||
argumentValue?: FText; | ||
} | ||
export interface ByteProperty extends BaseProperty { | ||
value: { | ||
unk1: string; | ||
unk2: number; | ||
enumName: string; | ||
valueName?: string; | ||
value?: number; | ||
}; | ||
} | ||
export interface EnumProperty extends BaseProperty { | ||
enum: string; | ||
value: string; | ||
value: { | ||
enum: string; | ||
value: string; | ||
}; | ||
} | ||
@@ -107,4 +120,6 @@ export interface ObjectProperty extends BaseProperty { | ||
export interface MapProperty extends BaseProperty { | ||
value: any; | ||
value: { | ||
[key: string]: any; | ||
}; | ||
} | ||
export declare type Property = IntProperty | BoolProperty | FloatProperty | StrProperty | NameProperty | TextProperty | ByteProperty | EnumProperty | ObjectProperty | StructProperty | ArrayProperty | MapProperty; | ||
export declare type Property = IntProperty | BoolProperty | FloatProperty | StringProperty | NameProperty | TextProperty | ByteProperty | EnumProperty | ObjectProperty | StructProperty | ArrayProperty | MapProperty; |
{ | ||
"name": "satisfactory-json", | ||
"version": "0.0.18", | ||
"version": "0.0.19", | ||
"description": "Convert Satisfactory save files to JSON and back", | ||
@@ -12,2 +12,5 @@ "main": "lib/index.js", | ||
"@types/node": "^12.0.4", | ||
"gulp": "^4.0.2", | ||
"gulp-plumber": "^1.2.1", | ||
"gulp-typescript": "^5.0.1", | ||
"ts-node": "^8.3.0", | ||
@@ -18,4 +21,4 @@ "tslint": "^5.17.0", | ||
"scripts": { | ||
"build": "tsc", | ||
"build:watch": "tsc --watch", | ||
"build": "gulp", | ||
"build:watch": "gulp watch", | ||
"lint": "tslint --project \"./tsconfig.json\"", | ||
@@ -22,0 +25,0 @@ "prepublish": "yarn build", |
@@ -14,1 +14,21 @@ # satisfactory-json | ||
``` | ||
--- | ||
## Notes | ||
### What does the preprocessor do? | ||
The goal was to achieve bidirectional transformations from Archive to the variable as in the Unreal code. This is useful, because binary data has to be read in the same way it was written, so writing that code once saves the effort to keep the two functions in sync. | ||
``` | ||
ar << property.name; | ||
``` | ||
Problem is, TypeScript passes parameters by value and not by reference. The only way to be able to read or write to a variable seems to be to pass an object and a key to a variable in it: | ||
```ts | ||
ar.transformString(property, 'name'); | ||
``` | ||
By using strings as key we lose the most important feature of TypeScript, the Type Safety. So I wrote a preprocessor that converts the following code to the code above before sending it t the TypeScript compiler so that we can have the best of both worlds. | ||
```ts | ||
ar.transformString(property.name); | ||
``` | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34
68574
7
83
1808