Skip to content

Commit 8d8646e

Browse files
committed
Bitread v0.2.1 (API changes)
1 parent 1201fea commit 8d8646e

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

Gopkg.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
[[constraint]]
3737
name = "github.com/markus-wa/gobitread"
38-
version = "0.1.0"
38+
version = "0.2.1"
3939

4040
[[constraint]]
4141
name = "github.com/markus-wa/godispatch"

packet_handlers.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func (p *Parser) handlePacketEntities(pe *msg.CSVCMsg_PacketEntities) {
5757
}
5858

5959
func (p *Parser) readEnterPVS(reader *bit.BitReader, entityID int) *st.Entity {
60-
scID := int(reader.ReadInt(uint(p.stParser.ClassBits())))
60+
scID := int(reader.ReadInt(p.stParser.ClassBits()))
6161
reader.ReadInt(10) // Serial Number
6262

6363
newEntity := st.NewEntity(entityID, p.stParser.ServerClasses()[scID])
@@ -563,7 +563,7 @@ func (p *Parser) handleCreateStringTable(tab *msg.CSVCMsg_CreateStringTable) {
563563
}
564564

565565
nTmp := tab.MaxEntries
566-
var nEntryBits uint
566+
nEntryBits := 0
567567

568568
for nTmp != 0 {
569569
nTmp = nTmp >> 1
@@ -608,7 +608,7 @@ func (p *Parser) handleCreateStringTable(tab *msg.CSVCMsg_CreateStringTable) {
608608
if br.ReadBit() {
609609
if tab.UserDataFixedSize {
610610
// Should always be < 8 bits => use faster ReadBitsToByte() over ReadBits()
611-
userdat = []byte{br.ReadBitsToByte(uint(tab.UserDataSizeBits))}
611+
userdat = []byte{br.ReadBitsToByte(int(tab.UserDataSizeBits))}
612612
} else {
613613
userdat = br.ReadBytes(int(br.ReadInt(14)))
614614
}

sendtables/propdecoder.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,17 @@ func (propertyDecoder) decodeInt(prop *sendTableProperty, reader *bit.BitReader)
7575
return int(reader.ReadSignedVarInt32())
7676
}
7777
if prop.flags.hasFlagSet(propFlagUnsigned) {
78-
return int(reader.ReadInt(uint(prop.numberOfBits)))
78+
return int(reader.ReadInt(prop.numberOfBits))
7979
}
80-
return reader.ReadSignedInt(uint(prop.numberOfBits))
80+
return reader.ReadSignedInt(prop.numberOfBits)
8181
}
8282

8383
func (propertyDecoder) decodeFloat(prop *sendTableProperty, reader *bit.BitReader) float32 {
8484
if prop.flags&specialFloatFlags != 0 {
8585
return propDecoder.decodeSpecialFloat(prop, reader)
8686
}
8787

88-
dwInterp := reader.ReadInt(uint(prop.numberOfBits))
88+
dwInterp := reader.ReadInt(prop.numberOfBits)
8989
return prop.lowValue + ((prop.highValue - prop.lowValue) * (float32(dwInterp) / float32((int(1)<<uint(prop.numberOfBits))-1)))
9090
}
9191

@@ -105,11 +105,11 @@ func (propertyDecoder) decodeSpecialFloat(prop *sendTableProperty, reader *bit.B
105105
} else if prop.flags.hasFlagSet(propFlagNormal) {
106106
return propDecoder.readBitNormal(reader)
107107
} else if prop.flags.hasFlagSet(propFlagCellCoord) {
108-
return propDecoder.readBitCellCoord(reader, uint(prop.numberOfBits), false, false)
108+
return propDecoder.readBitCellCoord(reader, prop.numberOfBits, false, false)
109109
} else if prop.flags.hasFlagSet(propFlagCellCoordLowPrecision) {
110-
return propDecoder.readBitCellCoord(reader, uint(prop.numberOfBits), true, false)
110+
return propDecoder.readBitCellCoord(reader, prop.numberOfBits, true, false)
111111
} else if prop.flags.hasFlagSet(propFlagCellCoordIntegral) {
112-
return propDecoder.readBitCellCoord(reader, uint(prop.numberOfBits), false, true)
112+
return propDecoder.readBitCellCoord(reader, prop.numberOfBits, false, true)
113113
}
114114
panic(fmt.Sprintf("Unexpected special float flag (Flags %v)", prop.flags))
115115
}
@@ -196,7 +196,7 @@ func (propertyDecoder) readBitNormal(reader *bit.BitReader) float32 {
196196
return res
197197
}
198198

199-
func (propertyDecoder) readBitCellCoord(reader *bit.BitReader, bits uint, isIntegral bool, isLowPrecision bool) float32 {
199+
func (propertyDecoder) readBitCellCoord(reader *bit.BitReader, bits int, isIntegral bool, isLowPrecision bool) float32 {
200200
var intVal, fractVal int
201201
var res float32
202202

@@ -245,7 +245,7 @@ func (propertyDecoder) decodeVector(prop *sendTableProperty, reader *bit.BitRead
245245
func (propertyDecoder) decodeArray(fProp *FlattenedPropEntry, reader *bit.BitReader) []PropValue {
246246
numElement := fProp.prop.numberOfElements
247247

248-
var numBits uint = 1
248+
numBits := 1
249249

250250
for maxElements := (numElement >> 1); maxElements != 0; maxElements = maxElements >> 1 {
251251
numBits++

0 commit comments

Comments
 (0)