Skip to content

Commit c3d9618

Browse files
committed
core: delete AditionalEventEmitters and package fuzzy (#21)
The maintenance cost outweights the use of it, especially now that we have better side-switching events.
1 parent 3f5cadd commit c3d9618

File tree

4 files changed

+0
-140
lines changed

4 files changed

+0
-140
lines changed

demoinfocs_test.go

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
dem "github.com/markus-wa/demoinfocs-golang"
2020
common "github.com/markus-wa/demoinfocs-golang/common"
2121
events "github.com/markus-wa/demoinfocs-golang/events"
22-
fuzzy "github.com/markus-wa/demoinfocs-golang/fuzzy"
2322
msg "github.com/markus-wa/demoinfocs-golang/msg"
2423
)
2524

@@ -178,50 +177,6 @@ func TestUnexpectedEndOfDemo(t *testing.T) {
178177
}
179178
}
180179

181-
func TestValveMatchmakingFuzzyEmitters(t *testing.T) {
182-
f, err := os.Open(valveMatchmakingDemoPath)
183-
if err != nil {
184-
t.Fatal(err)
185-
}
186-
defer f.Close()
187-
188-
cfg := dem.DefaultParserConfig
189-
cfg.AdditionalEventEmitters = []dem.EventEmitter{new(fuzzy.ValveMatchmakingTeamSwitchEmitter)}
190-
191-
p := dem.NewParserWithConfig(f, cfg)
192-
193-
teamSwitchDone := false
194-
tScoreBeforeSwap, ctScoreBeforeSwap := -1, -1
195-
p.RegisterEventHandler(func(ev events.RoundEnd) {
196-
switch ev.Winner {
197-
case common.TeamTerrorists:
198-
tScoreBeforeSwap = p.GameState().TeamTerrorists().Score + 1
199-
200-
case common.TeamCounterTerrorists:
201-
ctScoreBeforeSwap = p.GameState().TeamCounterTerrorists().Score + 1
202-
}
203-
})
204-
205-
p.RegisterEventHandler(func(fuzzy.TeamSwitchEvent) {
206-
teamSwitchDone = true
207-
if tScoreBeforeSwap != p.GameState().TeamCounterTerrorists().Score {
208-
t.Error("T-Score before swap != CT-Score after swap")
209-
}
210-
if ctScoreBeforeSwap != p.GameState().TeamTerrorists().Score {
211-
t.Error("CT-Score before swap != T-Score after swap")
212-
}
213-
})
214-
215-
err = p.ParseToEnd()
216-
if err != nil {
217-
t.Fatal("Parsing failed:", err)
218-
}
219-
220-
if !teamSwitchDone {
221-
t.Fatal("TeamSwitchEvent not received")
222-
}
223-
}
224-
225180
func TestCancelParseToEnd(t *testing.T) {
226181
f, err := os.Open(defaultDemPath)
227182
if err != nil {

fuzzy/doc.go

Lines changed: 0 additions & 2 deletions
This file was deleted.

fuzzy/team_switch.go

Lines changed: 0 additions & 75 deletions
This file was deleted.

parser.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -210,20 +210,6 @@ type ParserConfig struct {
210210
// Check out demopacket.go to see which net-messages are already being parsed by default.
211211
// This is a beta feature and may be changed or replaced without notice.
212212
AdditionalNetMessageCreators map[int]NetMessageCreator
213-
214-
// AdditionalEventEmitters contains additional event emitters - either from the fuzzy package or custom ones.
215-
// This is mainly used to add logic specifically for one type of demo (e.g. Matchmaking, FaceIt etc.).
216-
// This is a beta feature and may be changed or replaced without notice.
217-
// See also: package fuzzy for existing emitters with fuzzy-logic that depends on the demo-type.
218-
AdditionalEventEmitters []EventEmitter
219-
}
220-
221-
// EventEmitter is the interface to define additional event-emitters.
222-
// The emitters may fire additional events by calling the eventDispatcher function received during registration of the emitter.
223-
//
224-
// See also: package fuzzy for existing emitters with fuzzy-logic that depends on the demo-type.
225-
type EventEmitter interface {
226-
Register(parser *Parser, eventDispatcher func(event interface{}))
227213
}
228214

229215
// DefaultParserConfig is the default Parser configuration used by NewParser().
@@ -263,10 +249,6 @@ func NewParserWithConfig(demostream io.Reader, config ParserConfig) *Parser {
263249

264250
p.additionalNetMessageCreators = config.AdditionalNetMessageCreators
265251

266-
for _, emitter := range config.AdditionalEventEmitters {
267-
emitter.Register(&p, p.eventDispatcher.Dispatch)
268-
}
269-
270252
return &p
271253
}
272254

0 commit comments

Comments
 (0)