mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-09-27 21:56:19 -04:00
dc6 refactor: lintfix
This commit is contained in:
parent
6d098de778
commit
622e54dfce
@ -51,6 +51,7 @@ func New() *DC6 {
|
|||||||
// Load loads a dc6 animation
|
// Load loads a dc6 animation
|
||||||
func Load(data []byte) (*DC6, error) {
|
func Load(data []byte) (*DC6, error) {
|
||||||
d := New()
|
d := New()
|
||||||
|
|
||||||
err := d.Unmarshal(data)
|
err := d.Unmarshal(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -60,29 +61,29 @@ func Load(data []byte) (*DC6, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Unmarshal converts bite slice into DC6 structure
|
// Unmarshal converts bite slice into DC6 structure
|
||||||
func (dc *DC6) Unmarshal(data []byte) error {
|
func (d *DC6) Unmarshal(data []byte) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
r := d2datautils.CreateStreamReader(data)
|
r := d2datautils.CreateStreamReader(data)
|
||||||
|
|
||||||
err = dc.loadHeader(r)
|
err = d.loadHeader(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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++ {
|
for i := 0; i < frameCount; i++ {
|
||||||
dc.FramePointers[i], err = r.ReadUInt32()
|
d.FramePointers[i], err = r.ReadUInt32()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ func getExampleDC6() *DC6 {
|
|||||||
FramesPerDirection: 1,
|
FramesPerDirection: 1,
|
||||||
FramePointers: []uint32{56},
|
FramePointers: []uint32{56},
|
||||||
Frames: []*DC6Frame{
|
Frames: []*DC6Frame{
|
||||||
&DC6Frame{
|
{
|
||||||
Flipped: 0,
|
Flipped: 0,
|
||||||
Width: 32,
|
Width: 32,
|
||||||
Height: 26,
|
Height: 26,
|
||||||
@ -64,6 +64,6 @@ func TestDC6Clone(t *testing.T) {
|
|||||||
if exampleDC6.Termination[0] != clonedDC6.Termination[0] ||
|
if exampleDC6.Termination[0] != clonedDC6.Termination[0] ||
|
||||||
len(exampleDC6.Frames) != len(clonedDC6.Frames) ||
|
len(exampleDC6.Frames) != len(clonedDC6.Frames) ||
|
||||||
exampleDC6.Frames[0].NextBlock != clonedDC6.Frames[0].NextBlock {
|
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")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user