From 4c3b74e776be89eb784672c63edf8ee896a7b9c0 Mon Sep 17 00:00:00 2001 From: Anonymous <84868516+Captian-obvious@users.noreply.github.com> Date: Mon, 23 Oct 2023 11:48:56 -0400 Subject: [PATCH] Update binary.py --- pyrbxm/binary.py | 87 +++++++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 45 deletions(-) diff --git a/pyrbxm/binary.py b/pyrbxm/binary.py index f345271..755211b 100644 --- a/pyrbxm/binary.py +++ b/pyrbxm/binary.py @@ -4,53 +4,41 @@ from io import BytesIO from dataclasses import dataclass import numpy as np - from .tree import PropertyType, Instance - -""" -using RobloxFiles.Enums; -using RobloxFiles.DataTypes; -using RobloxFiles.Utility; -""" - - # https://blog.roblox.com/2013/05/condense-and-compress-our-custom-binary-file-format/ def decode_int(i): return (i >> 1) ^ (-(i & 1)) - - +##end def encode_int(i): return (i << 1) ^ (i >> 31) - - +##end # http://stackoverflow.com/questions/442188/readint-readbyte-readstring-etc-in-python class BinaryStream: UINT32 = np.dtype(">i4") F32 = np.dtype(">f4") - def __init__(self, base_stream): self.base_stream = base_stream - + ##end def read_bytes(self, length) -> bytes: return self.base_stream.read(length) - + ##end def write_bytes(self, value): self.base_stream.write(value) - + ##end def unpack(self, fmt): return struct.unpack(fmt, self.read_bytes(struct.calcsize(fmt))) - + ##end def pack(self, fmt, *data): return self.write_bytes(struct.pack(fmt, *data)) - + ##end def read_string(self): (length,) = self.unpack("