Skip to content

Commit

Permalink
Update binary.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Captian-obvious authored Oct 23, 2023
1 parent 86256e3 commit 032852f
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions pyrbxm/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,31 +180,30 @@ class PROP:
Name: str = ""
ClassIndex: int = -1
Type: PropertyType = PropertyType.Unknown

@property
def Class(self):
return self.File.Classes[self.ClassIndex]

##end
@property
def ClassName(self):
return self.Class.ClassName if self.Class else "UnknownClass"

##end
def __str__(self):
return f"{self.Type} {self.ClassName}.{self.Name}"

##end
def deserialize(self, stream: BinaryStream, file: RobloxBinaryFile):
self.File = file
(self.ClassIndex,) = stream.unpack("<i")
self.Name = stream.read_string()

(propType,) = stream.unpack("<b")
self.Type = PropertyType(propType)

assert (
self.Class is not None
), f"Unknown class index {self.ClassIndex} (@ {self})!"
ids = self.Class.InstanceIds
instCount = self.Class.NumInstances
##end
##end


class BinaryRobloxFileChunk:
Expand All @@ -223,15 +222,15 @@ def __init__(self):
self.HasWriteBuffer = False
self.WriteBuffer = bytearray()
self.Handler = None

##end
@property
def HasCompressedData(self):
return self.CompressedSize > 0

##end
def __str__(self):
chunkType = self.ChunkType.replace(b"\0", b" ")
return f"'{chunkType}' Chunk ({self.Size} bytes) [{self.Handler}]"

##end
def deserialize(self, stream: BinaryStream):
(
self.ChunkType,
Expand All @@ -246,6 +245,9 @@ def deserialize(self, stream: BinaryStream):
# print(self.Data)
else:
self.Data = stream.read_bytes(self.Size)
##endif
##end
##end


class BinaryRobloxFile(Instance): # (RobloxFile):
Expand All @@ -272,15 +274,15 @@ def __init__(self):
self.Name = "Bin:"
self.Referent = "-1"
self.ParentLocked = True

##end
@property
def Chunks(self):
return self.ChunksImpl

##end
@property
def HasMetadata(self):
return self.META is not None

##end
@property
def Metadata(self):
return self.META.Data if self.META else {}
Expand Down

0 comments on commit 032852f

Please sign in to comment.