11package demoinfocs
22
33import (
4- "fmt"
54 "io"
6- "os"
75 "sync"
86
97 r3 "github.com/golang/geo/r3"
@@ -44,7 +42,6 @@ type Parser struct {
4442 gameEventDescs map [int32 ]* msg.CSVCMsg_GameEventListDescriptorT
4543 stringTables []* msg.CSVCMsg_CreateStringTable
4644 cancelChan chan struct {}
47- warn WarnHandler
4845 err error
4946 errLock sync.Mutex
5047}
@@ -129,24 +126,12 @@ func (p *Parser) setError(err error) {
129126 }
130127}
131128
132- // TODO: Maybe we should use a channel instead of that WarnHandler stuff
133-
134- // WarnHandler is a function that handles warnings of a Parser.
135- type WarnHandler func (string )
136-
137- // WarnToStdErr is a WarnHandler that prints all warnings to standard error output.
138- func WarnToStdErr (warning string ) {
139- fmt .Fprintln (os .Stderr , warning )
140- }
141-
142129// TODO: Change the New* methods (names + parameters)
143130
144131// NewParser creates a new Parser on the basis of an io.Reader
145132// - like os.File or bytes.Reader - that reads demo data.
146- // Any warnings that don't stop the Parser from doing it's job
147- // will be passed to the warnHandler if it's not nil.
148- func NewParser (demostream io.Reader , warnHandler WarnHandler ) * Parser {
149- return NewParserWithBufferSize (demostream , - 1 , warnHandler )
133+ func NewParser (demostream io.Reader ) * Parser {
134+ return NewParserWithBufferSize (demostream , - 1 )
150135}
151136
152137// NewParserWithBufferSize returns a new Parser with a custom msgQueue buffer size.
@@ -155,7 +140,7 @@ func NewParser(demostream io.Reader, warnHandler WarnHandler) *Parser {
155140// A negative value will make the Parser automatically decide the buffer size during ParseHeader()
156141// based on the number of ticks in the demo (nubmer of ticks = buffer size).
157142// See also: NewParser()
158- func NewParserWithBufferSize (demostream io.Reader , msgQueueBufferSize int , warnHandler WarnHandler ) * Parser {
143+ func NewParserWithBufferSize (demostream io.Reader , msgQueueBufferSize int ) * Parser {
159144 var p Parser
160145 // Init parser
161146 p .bitReader = bit .NewLargeBitReader (demostream )
@@ -168,7 +153,6 @@ func NewParserWithBufferSize(demostream io.Reader, msgQueueBufferSize int, warnH
168153 p .triggers = make (map [int ]* boundingBoxInformation )
169154 p .cancelChan = make (chan struct {}, 1 )
170155 p .gameState = newGameState ()
171- p .warn = warnHandler
172156
173157 // Attach proto msg handlers
174158 p .msgDispatcher .RegisterHandler (p .handlePacketEntities )
0 commit comments