Skip to content

Commit

Permalink
Merge pull request #3 from alexkar598/patch-1
Browse files Browse the repository at this point in the history
Fixes endianess (again)
  • Loading branch information
tigercat2000 authored Mar 20, 2022
2 parents b7a8264 + 63d5a08 commit 258d955
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ class http2byond {
var sizebytes = jspack.jspack.Unpack("H", sizearray); // It's packed in an unsigned short format, so unpack it as an unsigned short.
var size = sizebytes[0] - 1; // Byte size of the string/floating-point (minus the identifier byte).

if (dbuff[4] == 0x2a) { // 4-byte big-endian floating point data.
if (dbuff[4] == 0x2a) { // 4-byte little-endian floating point data.
var unpackarray = [dbuff[5], dbuff[6], dbuff[7], dbuff[8]];
var unpackint = jspack.jspack.Unpack("f", unpackarray); // 4 possible bytes, add them up and unpack as a big-endian (network) float
var unpackint = jspack.jspack.Unpack("<f", unpackarray); // 4 possible bytes, add them up and unpack as a little-endian (network) float
return unpackint[0];
} else if (dbuff[4] == 0x06) { // ASCII String.
var unpackString = "";
Expand Down Expand Up @@ -163,4 +163,4 @@ class http2byond {
}
};

module.exports = http2byond;
module.exports = http2byond;

0 comments on commit 258d955

Please sign in to comment.