Skip to content

Commit 59280ef

Browse files
committed
add Parser.poolBitReader() util func
1 parent b0d84be commit 59280ef

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

pkg/demoinfocs/net_messages.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,7 @@ func (p *parser) handlePacketEntities(pe *msg.CSVCMsg_PacketEntities) {
4747
}
4848
}
4949

50-
err := r.Pool()
51-
if err != nil {
52-
p.eventDispatcher.Dispatch(events.ParserWarn{
53-
Message: err.Error(),
54-
})
55-
}
50+
p.poolBitReader(r)
5651
}
5752

5853
func (p *parser) handleSetConVar(setConVar *msg.CNETMsg_SetConVar) {

pkg/demoinfocs/parser.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414

1515
bit "github.com/markus-wa/demoinfocs-golang/v2/internal/bitread"
1616
common "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/common"
17+
"github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/events"
1718
msg "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/msg"
1819
st "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/sendtables"
1920
)
@@ -277,6 +278,15 @@ func (p *parser) setError(err error) {
277278
p.errLock.Unlock()
278279
}
279280

281+
func (p *parser) poolBitReader(r *bit.BitReader) {
282+
err := r.Pool()
283+
if err != nil {
284+
p.eventDispatcher.Dispatch(events.ParserWarn{
285+
Message: err.Error(),
286+
})
287+
}
288+
}
289+
280290
// NewParser creates a new Parser with the default configuration.
281291
// The demostream io.Reader (e.g. os.File or bytes.Reader) must provide demo data in the '.DEM' format.
282292
//

pkg/demoinfocs/stringtables.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ func (p *parser) processStringTable(tab *msg.CSVCMsg_CreateStringTable) {
264264
p.processModelPreCacheUpdate()
265265
}
266266

267-
br.Pool()
267+
p.poolBitReader(br)
268268
}
269269

270270
func parsePlayerInfo(reader io.Reader) *playerInfo {

0 commit comments

Comments
 (0)