diff --git a/d2common/d2fileformats/d2dc6/dc6.go b/d2common/d2fileformats/d2dc6/dc6.go index 2c10f9e7..0426f4f3 100644 --- a/d2common/d2fileformats/d2dc6/dc6.go +++ b/d2common/d2fileformats/d2dc6/dc6.go @@ -51,6 +51,7 @@ func New() *DC6 { // Load loads a dc6 animation func Load(data []byte) (*DC6, error) { d := New() + err := d.Unmarshal(data) if err != nil { return nil, err @@ -60,29 +61,29 @@ func Load(data []byte) (*DC6, error) { } // Unmarshal converts bite slice into DC6 structure -func (dc *DC6) Unmarshal(data []byte) error { +func (d *DC6) Unmarshal(data []byte) error { var err error r := d2datautils.CreateStreamReader(data) - err = dc.loadHeader(r) + err = d.loadHeader(r) if err != nil { return err } - frameCount := int(dc.Directions * dc.FramesPerDirection) + frameCount := int(d.Directions * d.FramesPerDirection) - dc.FramePointers = make([]uint32, frameCount) + d.FramePointers = make([]uint32, frameCount) for i := 0; i < frameCount; i++ { - dc.FramePointers[i], err = r.ReadUInt32() + d.FramePointers[i], err = r.ReadUInt32() if err != nil { return err } } - dc.Frames = make([]*DC6Frame, frameCount) + d.Frames = make([]*DC6Frame, frameCount) - if err := dc.loadFrames(r); err != nil { + if err := d.loadFrames(r); err != nil { return err } diff --git a/d2common/d2fileformats/d2dc6/dc6_test.go b/d2common/d2fileformats/d2dc6/dc6_test.go index 2c4a0e8e..3da98399 100644 --- a/d2common/d2fileformats/d2dc6/dc6_test.go +++ b/d2common/d2fileformats/d2dc6/dc6_test.go @@ -22,7 +22,7 @@ func getExampleDC6() *DC6 { FramesPerDirection: 1, FramePointers: []uint32{56}, Frames: []*DC6Frame{ - &DC6Frame{ + { Flipped: 0, Width: 32, Height: 26, @@ -64,6 +64,6 @@ func TestDC6Clone(t *testing.T) { if exampleDC6.Termination[0] != clonedDC6.Termination[0] || len(exampleDC6.Frames) != len(clonedDC6.Frames) || exampleDC6.Frames[0].NextBlock != clonedDC6.Frames[0].NextBlock { - t.Fatal("cloned dc6 isn't equal to orginal") + t.Fatal("cloned dc6 isn't equal to original") } }