Skip to content

Commit

Permalink
Merge pull request #27 from Galaco/refactor
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
Galaco authored Mar 28, 2019
2 parents 208dcd7 + 26a12a6 commit 4bfb611
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lumps/leaf.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ func (lump *Leaf) Unmarshall(raw []byte) (err error) {
i := 0

for i < numLeafs {
rawLeaf := bytes.NewBuffer(raw[(structSize * i) : (structSize*i)+structSize])
leafBuf := make([]byte, structSize)
copy(leafBuf, raw[(structSize * i) : (structSize*i)+structSize])
// Pad the raw data to the correct size of a leaf
if lump.Version() > maxBspVersionOfV0Leaf {
rawLeaf.Write(make([]byte, int(unsafe.Sizeof(common.CompressedLightCube{}))))
leafBuf = append(leafBuf, make([]byte, int(unsafe.Sizeof(common.CompressedLightCube{})))...)
}
rawLeaf := bytes.NewBuffer(leafBuf)
err = binary.Read(rawLeaf, binary.LittleEndian, &lump.data[i])
if err != nil {
return err
Expand Down

0 comments on commit 4bfb611

Please sign in to comment.