satisfactory-json
Advanced tools
Comparing version 0.0.58 to 0.0.59
@@ -13,2 +13,3 @@ /// <reference types="node" /> | ||
abstract transformFloat(ctx: Context, ref: Reference, shouldCount: boolean): boolean; | ||
abstract transformDouble(ctx: Context, ref: Reference, shouldCount: boolean): boolean; | ||
abstract assertNullByte(ctx: Context, shouldCount: boolean): boolean; | ||
@@ -28,2 +29,3 @@ abstract transformHex(ctx: Context, ref: Reference, bytes: number, shouldCount: boolean): boolean; | ||
transformFloat(ctx: Context, ref: Reference, shouldCount: boolean): boolean; | ||
transformDouble(ctx: Context, ref: Reference, shouldCount: boolean): boolean; | ||
assertNullByte(ctx: Context, shouldCount: boolean): boolean; | ||
@@ -49,2 +51,3 @@ transformHex(ctx: Context, ref: Reference, bytes: number, shouldCount: boolean): boolean; | ||
readFloat(_shouldCount?: boolean): number | undefined; | ||
readDouble(_shouldCount?: boolean): number | undefined; | ||
readUntil(length: number, shouldCount: boolean): Buffer | undefined; | ||
@@ -77,2 +80,3 @@ setRollbackPoint(): void; | ||
transformFloat(ctx: Context, ref: Reference, shouldCount: boolean): boolean; | ||
transformDouble(ctx: Context, ref: Reference, shouldCount: boolean): boolean; | ||
private write; | ||
@@ -79,0 +83,0 @@ private writeBuffer; |
@@ -147,2 +147,10 @@ "use strict"; | ||
}; | ||
ReadArchive.prototype.transformDouble = function (ctx, ref, shouldCount) { | ||
var result = this.readDouble(shouldCount); | ||
if (result === undefined) { | ||
return false; | ||
} | ||
setVar(ctx, ref, result); | ||
return true; | ||
}; | ||
ReadArchive.prototype.assertNullByte = function (ctx, shouldCount) { | ||
@@ -283,3 +291,7 @@ var result = this.readByte(shouldCount); | ||
if (result_3 !== 0) { | ||
throw new Error("string(len: " + length + ") does not end with zero, but with " + result_3); | ||
// TODO russian characters for some reason do not end with double zero? | ||
console.error("string " + resultStr + " (len: " + length + ") does not end with double zero, but with " + result_3); | ||
/*throw new Error( | ||
`string(len: ${length}) does not end with zero, but with ${result}` | ||
);*/ | ||
} | ||
@@ -294,3 +306,4 @@ } | ||
if (result !== 0) { | ||
throw new Error("string(len: " + length + ") does not end with zero, but with " + result); | ||
throw new Error("string " + resultStr + " (len: " + length + ") does not end with zero, but with " + result); | ||
//console.error(`string ${resultStr} (len: ${length}) does not end with zero, but with ${result}`) | ||
} | ||
@@ -339,2 +352,15 @@ return resultStr; | ||
}; | ||
ReadArchive.prototype.readDouble = function (_shouldCount) { | ||
if (_shouldCount === void 0) { _shouldCount = true; } | ||
var bytes = 8; | ||
if (this.cursor + bytes > this.buffer.length) { | ||
// Not enough bytes in this chunk | ||
this.missingBytes = this.cursor + bytes - this.buffer.length; | ||
return undefined; | ||
} | ||
var result = this.buffer.readDoubleLE(this.cursor); | ||
this.cursor += bytes; | ||
this.bytesRead += bytes; | ||
return result; | ||
}; | ||
ReadArchive.prototype.readUntil = function (length, shouldCount) { | ||
@@ -535,2 +561,23 @@ //console.log('read', length, this.bytesRead); | ||
}; | ||
WriteArchive.prototype.transformDouble = function (ctx, ref, shouldCount) { | ||
var value = getVar(ctx, ref); | ||
if (value === undefined) { | ||
throw new Error("Undefined float " + ref.name); | ||
} | ||
var bytes = 8; | ||
if (shouldCount) { | ||
this.bufferLength += bytes; | ||
} | ||
this.totalBytes += bytes; | ||
if (this.cursor + bytes > MAX_CHUNK_SIZE) { | ||
// not enough place in the buffer | ||
var buffer = Buffer.alloc(bytes); | ||
buffer.writeDoubleLE(value, 0); | ||
this.putInNewChunk(buffer, bytes); | ||
return false; | ||
} | ||
this.buffer.writeDoubleLE(value, this.cursor); | ||
this.cursor += bytes; | ||
return true; | ||
}; | ||
WriteArchive.prototype.write = function (value, shouldCount) { | ||
@@ -537,0 +584,0 @@ var bytes = value.length; |
@@ -42,2 +42,3 @@ import { Name, Command, Context } from './commands'; | ||
float(name: Name): Builder; | ||
double(name: Name): Builder; | ||
hex(name: Name, bytes: number, shouldCount?: boolean): Builder; | ||
@@ -44,0 +45,0 @@ assertNullByte(shouldCount?: boolean): Builder; |
@@ -81,2 +81,6 @@ "use strict"; | ||
}; | ||
Builder.prototype.double = function (name) { | ||
this.commands.push(new commands_1.DoubleCommand(name)); | ||
return this; | ||
}; | ||
Builder.prototype.hex = function (name, bytes, shouldCount) { | ||
@@ -83,0 +87,0 @@ if (shouldCount === void 0) { shouldCount = true; } |
@@ -97,2 +97,7 @@ import { Archive } from './Archive'; | ||
} | ||
export declare class DoubleCommand extends Command { | ||
private ref; | ||
constructor(name: Name); | ||
exec(ctx: Context, ar: Archive): number; | ||
} | ||
export declare class AssertNullByteCommand extends Command { | ||
@@ -99,0 +104,0 @@ private shouldCount; |
@@ -18,3 +18,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.EmitEntityProgressCommand = exports.EndSaveGameCommand = exports.StartCompressionCommand = exports.DebuggerCommand = exports.BreakCommand = exports.SwitchCommand = exports.HexRemainingCommand = exports.BufferEndCommand = exports.BufferStartCommand = exports.ExecCommand = exports.CallCommand = exports.CondCommand = exports.LoopBodyCommand = exports.LoopHeaderCommand = exports.HexCommand = exports.AssertNullByteCommand = exports.FloatCommand = exports.ByteCommand = exports.LongCommand = exports.StrCommand = exports.IntCommand = exports.LeaveElemCommand = exports.EnterElemCommand = exports.LeaveArrayCommand = exports.EnterArrayCommand = exports.LeaveObjectCommand = exports.EnterObjectCommand = exports.Command = exports.ReferenceType = void 0; | ||
exports.EmitEntityProgressCommand = exports.EndSaveGameCommand = exports.StartCompressionCommand = exports.DebuggerCommand = exports.BreakCommand = exports.SwitchCommand = exports.HexRemainingCommand = exports.BufferEndCommand = exports.BufferStartCommand = exports.ExecCommand = exports.CallCommand = exports.CondCommand = exports.LoopBodyCommand = exports.LoopHeaderCommand = exports.HexCommand = exports.AssertNullByteCommand = exports.DoubleCommand = exports.FloatCommand = exports.ByteCommand = exports.LongCommand = exports.StrCommand = exports.IntCommand = exports.LeaveElemCommand = exports.EnterElemCommand = exports.LeaveArrayCommand = exports.EnterArrayCommand = exports.LeaveObjectCommand = exports.EnterObjectCommand = exports.Command = exports.ReferenceType = void 0; | ||
var Builder_1 = require("./Builder"); | ||
@@ -327,2 +327,19 @@ // Generate global ids for all commands | ||
exports.FloatCommand = FloatCommand; | ||
var DoubleCommand = /** @class */ (function (_super) { | ||
__extends(DoubleCommand, _super); | ||
function DoubleCommand(name) { | ||
var _this = _super.call(this) || this; | ||
_this.ref = buildReference(name); | ||
return _this; | ||
} | ||
DoubleCommand.prototype.exec = function (ctx, ar) { | ||
var result = ar.transformDouble(ctx, this.ref, true); | ||
if (!result) { | ||
return ar.missingBytes; | ||
} | ||
return 0; | ||
}; | ||
return DoubleCommand; | ||
}(Command)); | ||
exports.DoubleCommand = DoubleCommand; | ||
var AssertNullByteCommand = /** @class */ (function (_super) { | ||
@@ -329,0 +346,0 @@ __extends(AssertNullByteCommand, _super); |
@@ -18,2 +18,4 @@ "use strict"; | ||
var FINetworkTrace_1 = require("./structs/FINetworkTrace"); | ||
var FINLuaProcessorStateStorage_1 = require("./structs/FINLuaProcessorStateStorage"); | ||
var DateTime_1 = require("./structs/DateTime"); | ||
function transformStructProperty(builder) { | ||
@@ -78,2 +80,6 @@ builder | ||
FFPlotTask: function (builder) { return ArbitraryStruct_1.transformArbitraryStruct(builder); }, | ||
FINLuaProcessorStateStorage: function (builder) { | ||
return FINLuaProcessorStateStorage_1.transformFINLuaProcessorStateStorage(builder); | ||
}, | ||
DateTime: function (builder) { return DateTime_1.transformDateTime(builder); }, | ||
$default: function (builder) { | ||
@@ -80,0 +86,0 @@ return builder.error(function (ctx) { return "Unknown struct property: " + ctx.obj.type; }); |
@@ -8,3 +8,4 @@ "use strict"; | ||
function transformFINNetworkTrace(builder) { | ||
builder.int('valid').if(function (ctx) { return ctx.obj.valid; }, function (builder) { | ||
builder. /*int('valid').*/if(function (_) { return true; }, //ctx.obj.valid > 0, | ||
function (builder) { | ||
builder | ||
@@ -11,0 +12,0 @@ .str('levelName') |
@@ -86,2 +86,9 @@ "use strict"; | ||
}, | ||
'10' /*HISTORYTYPE_TRANSFORM*/: function (builder) { | ||
builder | ||
.obj('sourceText') | ||
.call(TransformationEngine_1.RegisteredFunction.transformFText) | ||
.endObj() | ||
.byte('transformType'); | ||
}, | ||
$default: function (builder) { | ||
@@ -88,0 +95,0 @@ builder.error(function (ctx) { return "Unhandled HistoryType: " + ctx.obj.historyType; }); |
@@ -62,2 +62,8 @@ "use strict"; | ||
}, | ||
UInt64Property: function (builder) { | ||
return builder.call(TransformationEngine_1.RegisteredFunction.transformInt64Property); | ||
}, | ||
DoubleProperty: function (builder) { | ||
return builder.call(TransformationEngine_1.RegisteredFunction.transformInt64Property); | ||
}, | ||
$default: function (builder) { | ||
@@ -64,0 +70,0 @@ return builder.error(function (ctx) { return "Unknown property: " + ctx.obj.type; }); |
{ | ||
"name": "satisfactory-json", | ||
"version": "0.0.58", | ||
"version": "0.0.59", | ||
"description": "Convert Satisfactory save files to JSON and back", | ||
"author": "ficsit-felix", | ||
"dependencies": { | ||
"jsbi": "^3.1.4", | ||
"pako": "^2.0.2" | ||
"jsbi": "^3.1.6", | ||
"pako": "^2.0.4" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^14.14.35", | ||
"@types/pako": "^1.0.1", | ||
"@typescript-eslint/eslint-plugin": "^4.18.0", | ||
"@typescript-eslint/parser": "^4.18.0", | ||
"@types/node": "^16.6.1", | ||
"@types/pako": "^1.0.2", | ||
"@typescript-eslint/eslint-plugin": "^4.29.1", | ||
"@typescript-eslint/parser": "^4.29.1", | ||
"commander": "^7.0.0", | ||
"eslint": "^7.16.0", | ||
"eslint-config-prettier": "^7.2.0", | ||
"eslint": "^7.32.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-prettier": "^3.3.0", | ||
"prettier": "^2.0.5", | ||
"ts-node": "^9.1.1", | ||
"typescript": "^4.1.3", | ||
"v8-profiler-next": "^1.3.0" | ||
"prettier": "^2.3.2", | ||
"ts-node": "^10.2.0", | ||
"typescript": "^4.3.5", | ||
"v8-profiler-next": "^1.4.2" | ||
}, | ||
@@ -24,0 +24,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
306947
168
4623
Updatedjsbi@^3.1.6
Updatedpako@^2.0.4