removed PushByte method from StreamWriter

This commit is contained in:
M. Sz 2021-02-01 11:20:44 +01:00
parent 0fec9473ed
commit 7781b2cd6b
3 changed files with 17 additions and 22 deletions

View File

@ -401,10 +401,10 @@ Loop:
case 257:
newvalue := bitstream.ReadBits(8)
outputstream.PushByte(byte(newvalue))
outputstream.PushBytes(byte(newvalue))
tail = insertNode(tail, newvalue)
default:
outputstream.PushByte(byte(decoded))
outputstream.PushBytes(byte(decoded))
}
}

View File

@ -21,15 +21,10 @@ func (v *StreamWriter) GetBytes() []byte {
return v.data.Bytes()
}
// PushByte writes a byte to the stream
func (v *StreamWriter) PushByte(val byte) {
v.data.WriteByte(val)
}
// PushBytes writes a byte slince to the stream
// PushBytes writes a bytes to the stream
func (v *StreamWriter) PushBytes(b ...byte) {
for _, i := range b {
v.PushByte(i)
v.data.WriteByte(i)
}
}

View File

@ -145,42 +145,42 @@ func Load(fileData []byte) (*COF, error) {
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(byte(c.NumberOfLayers))
sw.PushBytes(byte(c.FramesPerDirection))
sw.PushBytes(byte(c.NumberOfDirections))
sw.PushBytes(c.unknownHeaderBytes...)
sw.PushByte(byte(c.Speed))
sw.PushBytes(byte(c.Speed))
sw.PushBytes(c.unknown1...)
for i := range c.CofLayers {
sw.PushByte(byte(c.CofLayers[i].Type.Int()))
sw.PushByte(c.CofLayers[i].Shadow)
sw.PushBytes(byte(c.CofLayers[i].Type.Int()))
sw.PushBytes(c.CofLayers[i].Shadow)
if c.CofLayers[i].Selectable {
sw.PushByte(byte(1))
sw.PushBytes(byte(1))
} else {
sw.PushByte(byte(0))
sw.PushBytes(byte(0))
}
if c.CofLayers[i].Transparent {
sw.PushByte(byte(1))
sw.PushBytes(byte(1))
} else {
sw.PushByte(byte(0))
sw.PushBytes(byte(0))
}
sw.PushByte(byte(c.CofLayers[i].DrawEffect))
sw.PushBytes(byte(c.CofLayers[i].DrawEffect))
sw.PushBytes(c.CofLayers[i].weaponClassByte...)
}
for _, i := range c.AnimationFrames {
sw.PushByte(byte(i))
sw.PushBytes(byte(i))
}
for direction := 0; direction < c.NumberOfDirections; direction++ {
for frame := 0; frame < c.FramesPerDirection; frame++ {
for i := 0; i < c.NumberOfLayers; i++ {
sw.PushByte(byte(c.Priority[direction][frame][i]))
sw.PushBytes(byte(c.Priority[direction][frame][i]))
}
}
}