Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/converter/properties/MapProperty.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import NoneProperty from "./NoneProperty.js";
import {writeBytes, writeInt32, writeFloat32, writeString, writeUint32} from "../value-writer.js";
import {writeBytes, writeInt32, writeFloat32, writeString, writeUint32, writeByte} from "../value-writer.js";
import {assignPrototype} from "../converter.js";

class MapProperty {
Expand Down Expand Up @@ -33,6 +33,7 @@ class MapProperty {
break;

case "StrProperty":
case "NameProperty":
currentKey = savReader.readString();
break;

Expand Down Expand Up @@ -64,6 +65,10 @@ class MapProperty {
currentValue = savReader.readBoolean();
break;

case "ByteProperty":
currentValue = savReader.readString();
break;

case "StrProperty":
currentValue = savReader.readString();
break;
Expand Down Expand Up @@ -98,6 +103,7 @@ class MapProperty {
break;

case "StrProperty":
case "NameProperty":
byteArrayContent = new Uint8Array([...byteArrayContent, ...writeString(currentKey)]);
break;

Expand Down Expand Up @@ -125,6 +131,10 @@ class MapProperty {
byteArrayContent = new Uint8Array([...byteArrayContent, ...writeString(currentValue)]);
break;

case "ByteProperty":
byteArrayContent = new Uint8Array([...byteArrayContent, ...writeString(currentValue)]);
break;

case "BoolProperty":
if (currentValue === true) {
byteArrayContent = new Uint8Array([...byteArrayContent, 0x01]);
Expand Down
4 changes: 4 additions & 0 deletions src/converter/value-writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export function writeFloat32(value) {
return array;
}

export function writeByte(value) {
return new Uint8Array([value]);
}

export function writeFloat64(value) {
const array = new Uint8Array(8);
new DataView(array.buffer).setFloat64(0, value, true);
Expand Down