1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-04 23:10:42 +00:00

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: case 257:
newvalue := bitstream.ReadBits(8) newvalue := bitstream.ReadBits(8)
outputstream.PushByte(byte(newvalue)) outputstream.PushBytes(byte(newvalue))
tail = insertNode(tail, newvalue) tail = insertNode(tail, newvalue)
default: default:
outputstream.PushByte(byte(decoded)) outputstream.PushBytes(byte(decoded))
} }
} }

View File

@ -21,15 +21,10 @@ func (v *StreamWriter) GetBytes() []byte {
return v.data.Bytes() return v.data.Bytes()
} }
// PushByte writes a byte to the stream // PushBytes writes a bytes to the stream
func (v *StreamWriter) PushByte(val byte) {
v.data.WriteByte(val)
}
// PushBytes writes a byte slince to the stream
func (v *StreamWriter) PushBytes(b ...byte) { func (v *StreamWriter) PushBytes(b ...byte) {
for _, i := range b { 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 { func (c *COF) Marshal() []byte {
sw := d2datautils.CreateStreamWriter() sw := d2datautils.CreateStreamWriter()
sw.PushByte(byte(c.NumberOfLayers)) sw.PushBytes(byte(c.NumberOfLayers))
sw.PushByte(byte(c.FramesPerDirection)) sw.PushBytes(byte(c.FramesPerDirection))
sw.PushByte(byte(c.NumberOfDirections)) sw.PushBytes(byte(c.NumberOfDirections))
sw.PushBytes(c.unknownHeaderBytes...) sw.PushBytes(c.unknownHeaderBytes...)
sw.PushByte(byte(c.Speed)) sw.PushBytes(byte(c.Speed))
sw.PushBytes(c.unknown1...) sw.PushBytes(c.unknown1...)
for i := range c.CofLayers { for i := range c.CofLayers {
sw.PushByte(byte(c.CofLayers[i].Type.Int())) sw.PushBytes(byte(c.CofLayers[i].Type.Int()))
sw.PushByte(c.CofLayers[i].Shadow) sw.PushBytes(c.CofLayers[i].Shadow)
if c.CofLayers[i].Selectable { if c.CofLayers[i].Selectable {
sw.PushByte(byte(1)) sw.PushBytes(byte(1))
} else { } else {
sw.PushByte(byte(0)) sw.PushBytes(byte(0))
} }
if c.CofLayers[i].Transparent { if c.CofLayers[i].Transparent {
sw.PushByte(byte(1)) sw.PushBytes(byte(1))
} else { } 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...) sw.PushBytes(c.CofLayers[i].weaponClassByte...)
} }
for _, i := range c.AnimationFrames { for _, i := range c.AnimationFrames {
sw.PushByte(byte(i)) sw.PushBytes(byte(i))
} }
for direction := 0; direction < c.NumberOfDirections; direction++ { for direction := 0; direction < c.NumberOfDirections; direction++ {
for frame := 0; frame < c.FramesPerDirection; frame++ { for frame := 0; frame < c.FramesPerDirection; frame++ {
for i := 0; i < c.NumberOfLayers; i++ { for i := 0; i < c.NumberOfLayers; i++ {
sw.PushByte(byte(c.Priority[direction][frame][i])) sw.PushBytes(byte(c.Priority[direction][frame][i]))
} }
} }
} }