dc6 refactor: lintfix

This commit is contained in:
M. Sz 2021-02-07 18:40:16 +01:00
parent 6d098de778
commit 622e54dfce
2 changed files with 10 additions and 9 deletions

View File

@ -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
}

View File

@ -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")
}
}