rename: PushBytes(b []byte) -> PushBytes(b ...byte)

This commit is contained in:
M. Sz 2021-02-01 11:15:42 +01:00
parent 0f32ad5d62
commit 0fec9473ed
2 changed files with 6 additions and 5 deletions

View File

@ -27,7 +27,7 @@ func (v *StreamWriter) PushByte(val byte) {
}
// PushBytes writes a byte slince to the stream
func (v *StreamWriter) PushBytes(b []byte) {
func (v *StreamWriter) PushBytes(b ...byte) {
for _, i := range b {
v.PushByte(i)
}

View File

@ -50,6 +50,7 @@ type COF struct {
}
// Load loads a COF file.
// nolint:funlen // no need to change
func Load(fileData []byte) (*COF, error) {
result := &COF{}
streamReader := d2datautils.CreateStreamReader(fileData)
@ -140,16 +141,16 @@ func Load(fileData []byte) (*COF, error) {
return result, nil
}
// Marshals encodes COF back into byte slince
// Marshal encodes COF back into byte slince
func (c *COF) Marshal() []byte {
sw := d2datautils.CreateStreamWriter()
sw.PushByte(byte(c.NumberOfLayers))
sw.PushByte(byte(c.FramesPerDirection))
sw.PushByte(byte(c.NumberOfDirections))
sw.PushBytes(c.unknownHeaderBytes)
sw.PushBytes(c.unknownHeaderBytes...)
sw.PushByte(byte(c.Speed))
sw.PushBytes(c.unknown1)
sw.PushBytes(c.unknown1...)
for i := range c.CofLayers {
sw.PushByte(byte(c.CofLayers[i].Type.Int()))
@ -169,7 +170,7 @@ func (c *COF) Marshal() []byte {
sw.PushByte(byte(c.CofLayers[i].DrawEffect))
sw.PushBytes(c.CofLayers[i].weaponClassByte)
sw.PushBytes(c.CofLayers[i].weaponClassByte...)
}
for _, i := range c.AnimationFrames {