From 1224a387962c4fb12cfd9649848b395ffde0adc2 Mon Sep 17 00:00:00 2001 From: gucio321 Date: Tue, 18 May 2021 19:49:47 +0200 Subject: [PATCH] d2common/d2datautils/StreamWriter: add Align method --- d2common/d2datautils/stream_writer.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/d2common/d2datautils/stream_writer.go b/d2common/d2datautils/stream_writer.go index 130fde63..ffee1af3 100644 --- a/d2common/d2datautils/stream_writer.go +++ b/d2common/d2datautils/stream_writer.go @@ -136,3 +136,10 @@ func (v *StreamWriter) PushUint64(val uint64) { v.data.WriteByte(byte(val >> 48)) v.data.WriteByte(byte(val >> 56)) } + +// Align aligns stream writer to bytes +func (v *StreamWriter) Align() { + if o := v.bitOffset % bitsPerByte; o > 0 { + v.PushBits(0, bitsPerByte-o) + } +}